[modules/brightness] Single quotes
This commit is contained in:
parent
e6181e2d94
commit
cfa4d0df48
1 changed files with 17 additions and 17 deletions
|
@ -1,12 +1,12 @@
|
||||||
# pylint: disable=C0111,R0903
|
# pylint: disable=C0111,R0903
|
||||||
|
|
||||||
"""Displays the brightness of a display
|
'''Displays the brightness of a display
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
* brightness.step: The amount of increase/decrease on scroll in % (defaults to 2)
|
* brightness.step: The amount of increase/decrease on scroll in % (defaults to 2)
|
||||||
* brightness.device_path: The device path (defaults to /sys/class/backlight/intel_backlight), can contain wildcards (in this case, the first matching path will be used)
|
* brightness.device_path: The device path (defaults to /sys/class/backlight/intel_backlight), can contain wildcards (in this case, the first matching path will be used)
|
||||||
|
|
||||||
"""
|
'''
|
||||||
|
|
||||||
import bumblebee.util
|
import bumblebee.util
|
||||||
import bumblebee.input
|
import bumblebee.input
|
||||||
|
@ -21,18 +21,18 @@ class Module(bumblebee.engine.Module):
|
||||||
bumblebee.output.Widget(full_text=self.brightness))
|
bumblebee.output.Widget(full_text=self.brightness))
|
||||||
self._brightness = 0
|
self._brightness = 0
|
||||||
|
|
||||||
self._device_path = self.find_device(self.parameter("device_path", "/sys/class/backlight/intel_backlight"))
|
self._device_path = self.find_device(self.parameter('device_path', '/sys/class/backlight/intel_backlight'))
|
||||||
step = self.parameter("step", 2)
|
step = self.parameter('step', 2)
|
||||||
|
|
||||||
if bumblebee.util.which("light"):
|
if bumblebee.util.which('light'):
|
||||||
self.register_cmd(engine, "light -A {}%".format(step),
|
self.register_cmd(engine, 'light -A {}%'.format(step),
|
||||||
"light -U {}%".format(step))
|
'light -U {}%'.format(step))
|
||||||
elif bumblebee.util.which("brightnessctl"):
|
elif bumblebee.util.which('brightnessctl'):
|
||||||
self.register_cmd(engine, "brightnessctl s {}%+".format(step),
|
self.register_cmd(engine, 'brightnessctl s {}%+'.format(step),
|
||||||
"brightnessctl s {}%-".format(step))
|
'brightnessctl s {}%-'.format(step))
|
||||||
else:
|
else:
|
||||||
self.register_cmd(engine, "xbacklight +{}%".format(step),
|
self.register_cmd(engine, 'xbacklight +{}%'.format(step),
|
||||||
"xbacklight -{}%".format(step))
|
'xbacklight -{}%'.format(step))
|
||||||
|
|
||||||
def find_device(self, device_path):
|
def find_device(self, device_path):
|
||||||
res = glob.glob(device_path)
|
res = glob.glob(device_path)
|
||||||
|
@ -46,18 +46,18 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
def brightness(self, widget):
|
def brightness(self, widget):
|
||||||
if isinstance(self._brightness, float):
|
if isinstance(self._brightness, float):
|
||||||
return "{:3.0f}%".format(self._brightness).strip()
|
return '{:3.0f}%'.format(self._brightness).strip()
|
||||||
else:
|
else:
|
||||||
return "n/a"
|
return 'n/a'
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
try:
|
try:
|
||||||
with open("{}/brightness".format(self._device_path)) as f:
|
with open('{}/brightness'.format(self._device_path)) as f:
|
||||||
backlight = int(f.readline())
|
backlight = int(f.readline())
|
||||||
with open("{}/max_brightness".format(self._device_path)) as f:
|
with open('{}/max_brightness'.format(self._device_path)) as f:
|
||||||
max_brightness = int(f.readline())
|
max_brightness = int(f.readline())
|
||||||
self._brightness = float(backlight * 100 / max_brightness)
|
self._brightness = float(backlight * 100 / max_brightness)
|
||||||
except:
|
except:
|
||||||
return "Error"
|
return 'Error'
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue