Skip to content

Commit

Permalink
conky module: fix tempfile and ignore new output (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntorresalberto authored Dec 3, 2024
1 parent bd35bc4 commit 2422a43
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions py3status/modules/conky.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,18 @@ def post_config_hook(self):
tmp = f"conky.config = {config}\nconky.text = [[{text}]]"

# write tmp output to '/tmp/py3status-conky_*', make a command
self.tmpfile = NamedTemporaryFile(prefix="py3status_conky-", suffix=".conf", delete=False)
self.tmpfile = NamedTemporaryFile(
prefix="py3status_conky-", suffix=".conf", delete_on_close=False
)
self.tmpfile.write(str.encode(tmp))
self.tmpfile.close()
self.conky_command = f"conky -c {self.tmpfile.name}".split()

# skip invalid conky errors
self.invalid_conky_errors = [
self.ignored_conky_outputs = [
"conky: invalid setting of type 'table'",
"conky: FOUND:",
"x11 session running",
]

# thread
Expand All @@ -399,7 +402,7 @@ def _start_loop(self):
while True:
line = self.process.stdout.readline().decode()
if self.process.poll() is not None or "conky:" in line:
if any(x in line for x in self.invalid_conky_errors):
if any(x in line for x in self.ignored_conky_outputs):
continue
raise Exception(line)
if self.line != line:
Expand Down

0 comments on commit 2422a43

Please sign in to comment.