From a4abdb28fffe966d6888a83d083685fadd17f7a1 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Sat, 14 May 2022 15:07:07 +0900 Subject: Use XDG_CACHE_HOME by default Previous setup broke down when XDG Base Directory Specifications were used. --- edit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'edit.py') 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): -- cgit v1.2.3-70-g09d2