From f4bcc781909342723f5f9d2d6a7647316936d7ac Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 26 Oct 2016 23:34:26 -0200 Subject: [PATCH] Allow redshift inhibition again --- i3pystatus/redshift.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i3pystatus/redshift.py b/i3pystatus/redshift.py index 8c03870..b6f031d 100644 --- a/i3pystatus/redshift.py +++ b/i3pystatus/redshift.py @@ -25,6 +25,7 @@ class RedshiftController(threading.Thread): self._temperature = 0 self._period = 'Unknown' self._location = (0.0, 0.0) + self._pid = None cmd = ["redshift"] + args if "-v" not in cmd: @@ -98,12 +99,13 @@ class RedshiftController(threading.Thread): def set_inhibit(self, inhibit): """Set inhibition state""" - if inhibit != self._inhibited: - os.kill(self._p.pid, signal.SIGUSR1) + if self._pid and inhibit != self._inhibited: + os.kill(self._pid, signal.SIGUSR1) self._inhibited = inhibit def run(self): with Popen(**self._params) as proc: + self._pid = proc.pid for line in proc.stdout: self.parse_output(line) proc.wait(10)