diff options
author | A Farzat <a@farzat.xyz> | 2022-05-14 15:07:07 +0900 |
---|---|---|
committer | A Farzat <a@farzat.xyz> | 2022-05-14 15:07:07 +0900 |
commit | a4abdb28fffe966d6888a83d083685fadd17f7a1 (patch) | |
tree | 42c23f566d8b49a95f5261610dff0d0cd127e7a1 /edit.py | |
parent | c1f6966d32f8c54a480fa60b20eb9e82c4a16a33 (diff) | |
download | edit-a4abdb28fffe966d6888a83d083685fadd17f7a1.tar.gz edit-a4abdb28fffe966d6888a83d083685fadd17f7a1.zip |
Use XDG_CACHE_HOME by default
Previous setup broke down when XDG Base Directory Specifications were
used.
Diffstat (limited to 'edit.py')
-rw-r--r-- | edit.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -20,12 +20,17 @@ import shlex import subprocess import weechat +def xdg_cache_dir(): + return os.path.expanduser(os.environ.get("XDG_CACHE_HOME", "~/..cache/")) -def weechat_config_dir(): +def weechat_cache_dir(): + cache_dir = os.path.join(xdg_cache_dir(), "weechat") + if os.path.exists(cache_dir): + return cache_dir return os.path.expanduser(os.environ.get("WEECHAT_HOME", "~/.weechat/")) -PATH = os.path.join(weechat_config_dir(), "message.txt") +PATH = os.path.join(weechat_cache_dir(), "message.txt") def editor_process_cb(data, command, return_code, out, err): |