[modules/caffeine] quotes

This commit is contained in:
tobi-wan-kenobi 2020-04-21 20:23:08 +02:00
parent 55a94ac770
commit 6ff8932c99

View file

@ -19,7 +19,7 @@ import bumblebee.engine
class Module(bumblebee.engine.Module): class Module(bumblebee.engine.Module):
def __init__(self, engine, config): def __init__(self, engine, config):
super(Module, self).__init__(engine, config, super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text="") bumblebee.output.Widget(full_text='')
) )
self._active = False self._active = False
self._xid = None self._xid = None
@ -37,10 +37,10 @@ class Module(bumblebee.engine.Module):
return missing return missing
def _get_i3bar_xid(self): def _get_i3bar_xid(self):
xid = bumblebee.util.execute("xdotool search --class \"i3bar\"").partition('\n')[0].strip() xid = bumblebee.util.execute('xdotool search --class \'i3bar\'').partition('\n')[0].strip()
if xid.isdigit(): if xid.isdigit():
return xid return xid
logging.warning("Module caffeine: xdotool couldn't get X window ID of \"i3bar\".") logging.warning('Module caffeine: xdotool couldn't get X window ID of \'i3bar\'.')
return None return None
def _notify(self): def _notify(self):
@ -48,9 +48,9 @@ class Module(bumblebee.engine.Module):
return return
if self._active: if self._active:
bumblebee.util.execute("notify-send \"Consuming caffeine\"") bumblebee.util.execute('notify-send \'Consuming caffeine\'')
else: else:
bumblebee.util.execute("notify-send \"Out of coffee\"") bumblebee.util.execute('notify-send \'Out of coffee\'')
def _suspend_screensaver(self): def _suspend_screensaver(self):
self._xid = self._get_i3bar_xid() self._xid = self._get_i3bar_xid()
@ -60,7 +60,7 @@ class Module(bumblebee.engine.Module):
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)
@ -79,13 +79,13 @@ class Module(bumblebee.engine.Module):
def state(self, _): def state(self, _):
if self._active: if self._active:
return "activated" return 'activated'
return "deactivated" return 'deactivated'
def _toggle(self, _): def _toggle(self, _):
missing = self._check_requirements() missing = self._check_requirements()
if missing: if missing:
logging.warning('Could not run caffeine - missing %s!', ", ".join(missing)) logging.warning('Could not run caffeine - missing %s!', ', '.join(missing))
return return
self._active = not self._active self._active = not self._active