Skip to content

Commit a5f799a

Browse files
committed
hl2file.py 0.3: add compatibility with WeeChat >= 3.2 (XDG directories)
1 parent a567acc commit a5f799a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

python/hl2file.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# This script generates a file containing a formatted list of highlights to be
1919
# used by an external program like conky.
2020
#
21+
# 2021-05-04, Sébastien Helleu <[email protected]>
22+
# 0.3: add compatibility with WeeChat >= 3.2 (XDG directories)
2123
# 2014-05-10, Sébastien Helleu <[email protected]>
2224
# 0.2: change hook_print callback argument type of displayed/highlight
2325
# (WeeChat >= 1.0)
@@ -36,7 +38,7 @@
3638

3739
name = "hl2file"
3840
author = "nesthib <[email protected]>"
39-
version = "0.2"
41+
version = "0.3"
4042
license = "GPL"
4143
description = "Generates a file with highlights for external programs like conky"
4244
shutdown_function = "shutdown"
@@ -70,7 +72,10 @@ def bufname(buffer):
7072
def write(my_file, content):
7173
if my_file == "":
7274
return
73-
my_file = os.path.expanduser(my_file.replace("%h", w.info_get("weechat_dir", "")))
75+
options = {
76+
'directory': 'data',
77+
}
78+
my_file = w.string_eval_path_home(my_file, {}, {}, options)
7479
try:
7580
f = open(my_file, 'w')
7681
except IOError:
@@ -134,8 +139,11 @@ def buffer_switch_cb(data, signal, signal_data):
134139
return w.WEECHAT_RC_OK
135140

136141
def shutdown():
142+
options = {
143+
'directory': 'data',
144+
}
137145
for my_file in ['output_file', 'output_active_buffer']:
138-
filename = w.config_get_plugin(my_file).replace("%h", w.info_get("weechat_dir", ""))
146+
filename = w.string_eval_path_home(my_file, {}, {}, options)
139147
if os.path.exists(filename):
140148
os.remove(filename)
141149
return w.WEECHAT_RC_OK

0 commit comments

Comments
 (0)