Make pylint happy

This commit is contained in:
mw 2019-09-02 16:42:25 +02:00
parent 4743558a68
commit 0b9829bc77

View file

@ -23,13 +23,13 @@ class Module(bumblebee.engine.Module):
) )
self._active = False self._active = False
self._xid = None self._xid = None
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self._toggle cmd=self._toggle
) )
def _check_requirements(self): def _check_requirements(self):
requirements = ['xdotool','xprop','xdg-screensaver'] requirements = ['xdotool', 'xprop', 'xdg-screensaver']
missing = [] missing = []
for tool in requirements: for tool in requirements:
if not bumblebee.util.which(tool): if not bumblebee.util.which(tool):
@ -56,27 +56,27 @@ class Module(bumblebee.engine.Module):
self._xid = self._get_i3bar_xid() self._xid = self._get_i3bar_xid()
if self._xid is None: if self._xid is None:
return return
pid = os.fork() pid = os.fork()
if pid == 0: if pid == 0:
os.setsid() os.setsid()
bumblebee.util.execute("xdg-screensaver suspend {}".format(self._xid)) bumblebee.util.execute("xdg-screensaver suspend {}".format(self._xid))
os._exit(0) os._exit(0)
else: else:
os.waitpid(pid,0) os.waitpid(pid, 0)
def _resume_screensaver(self): def _resume_screensaver(self):
for process in psutil.process_iter(): for process in psutil.process_iter():
if process.cmdline() == [bumblebee.util.which('xprop'),'-id',str(self._xid),'-spy']: if process.cmdline() == [bumblebee.util.which('xprop'), '-id', str(self._xid), '-spy']:
pid = process.pid pid = process.pid
os.kill(pid,9) os.kill(pid, 9)
def state(self, widget): def state(self, _):
if self._active: if self._active:
return "activated" return "activated"
return "deactivated" return "deactivated"
def _toggle(self, event): def _toggle(self, _):
missing = self._check_requirements() missing = self._check_requirements()
if missing: if missing:
logging.warning("Could not run caffeine - missing {}!".format(", ".join(missing))) logging.warning("Could not run caffeine - missing {}!".format(", ".join(missing)))