aboutsummaryrefslogtreecommitdiff
path: root/edit.py
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2022-05-14 15:07:07 +0900
committerA Farzat <a@farzat.xyz>2022-05-14 15:07:07 +0900
commita4abdb28fffe966d6888a83d083685fadd17f7a1 (patch)
tree42c23f566d8b49a95f5261610dff0d0cd127e7a1 /edit.py
parentc1f6966d32f8c54a480fa60b20eb9e82c4a16a33 (diff)
downloadedit-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.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/edit.py b/edit.py
index ca6ab3f..87a0403 100644
--- a/edit.py
+++ b/edit.py
@@ -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):