Skip to content

Commit 0a69a04

Browse files
committed
switch to ~HOME/.warnet for directories, if XDG not set
1 parent 7276fcd commit 0a69a04

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pip install -e .
112112
## Running
113113

114114
Warnet runs a daemon called `warnetd` which can be used to manage multiple warnets.
115-
`warnetd` will by default log to a file `$XDG_STATE_HOME/warnet/warnet.log` if the `$XDG_STATE_HOME` environment variable is set, otherwise it will use `$HOME/.local/state/warnet/warnet.log`.
115+
`warnetd` will by default log to a file `$XDG_STATE_HOME/warnet/warnet.log` if the `$XDG_STATE_HOME` environment variable is set, otherwise it will use `$HOME/.warnet/warnet.log`.
116116

117117
To start `warnetd` with your venv activated simply run:
118118

src/warnet/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ def gen_config_dir(network: str) -> Path:
326326
"""
327327
Determine a config dir based on network name
328328
"""
329-
xdg_config = os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
330-
config_dir = Path(xdg_config) / "warnet" / network
329+
config_dir = os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.warnet"))
330+
config_dir = Path(config_dir) / "warnet" / network
331331
return config_dir
332332

333333

src/warnet/warnetd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
WARNETD_PORT = 9276
3636

37-
# Determine the log file path based on XDG_STATE_HOME
38-
_xdg_state_home = os.environ.get(
39-
"XDG_STATE_HOME", os.path.join(os.environ["HOME"], ".local", "state")
37+
# Determine the log file path based on XDG_STATE_HOME, or ~/.warnet
38+
log_file_dir = os.environ.get(
39+
"XDG_STATE_HOME", os.path.join(os.environ["HOME"], ".warnet")
4040
)
41-
LOG_FILE_PATH = os.path.join(_xdg_state_home, "warnet", "warnet.log")
41+
LOG_FILE_PATH = os.path.join(log_file_dir, "warnet", "warnet.log")
4242

4343
# Ensure the directory exists
4444
os.makedirs(os.path.dirname(LOG_FILE_PATH), exist_ok=True)

0 commit comments

Comments
 (0)