|
18 | 18 | # This script generates a file containing a formatted list of highlights to be
|
19 | 19 | # used by an external program like conky.
|
20 | 20 | #
|
| 21 | +# 2021-05-04, Sébastien Helleu <[email protected]> |
| 22 | +# 0.3: add compatibility with WeeChat >= 3.2 (XDG directories) |
21 | 23 | # 2014-05-10, Sébastien Helleu <[email protected]>
|
22 | 24 | # 0.2: change hook_print callback argument type of displayed/highlight
|
23 | 25 | # (WeeChat >= 1.0)
|
|
36 | 38 |
|
37 | 39 | name = "hl2file"
|
38 | 40 | author = "nesthib <[email protected]>"
|
39 |
| -version = "0.2" |
| 41 | +version = "0.3" |
40 | 42 | license = "GPL"
|
41 | 43 | description = "Generates a file with highlights for external programs like conky"
|
42 | 44 | shutdown_function = "shutdown"
|
@@ -70,7 +72,10 @@ def bufname(buffer):
|
70 | 72 | def write(my_file, content):
|
71 | 73 | if my_file == "":
|
72 | 74 | 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) |
74 | 79 | try:
|
75 | 80 | f = open(my_file, 'w')
|
76 | 81 | except IOError:
|
@@ -134,8 +139,11 @@ def buffer_switch_cb(data, signal, signal_data):
|
134 | 139 | return w.WEECHAT_RC_OK
|
135 | 140 |
|
136 | 141 | def shutdown():
|
| 142 | + options = { |
| 143 | + 'directory': 'data', |
| 144 | + } |
137 | 145 | 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) |
139 | 147 | if os.path.exists(filename):
|
140 | 148 | os.remove(filename)
|
141 | 149 | return w.WEECHAT_RC_OK
|
|
0 commit comments