2016-12-10 14:31:18 +01:00
|
|
|
# pylint: disable=C0111,R0903
|
|
|
|
|
|
|
|
"""Displays the brightness of a display
|
|
|
|
|
2017-01-05 04:55:14 +01:00
|
|
|
Requires the following executable:
|
|
|
|
* xbacklight
|
|
|
|
|
2016-12-10 14:31:18 +01:00
|
|
|
Parameters:
|
|
|
|
* brightness.step: The amount of increase/decrease on scroll in % (defaults to 2)
|
2017-01-05 04:55:14 +01:00
|
|
|
|
2016-12-10 14:31:18 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
import bumblebee.input
|
|
|
|
import bumblebee.output
|
|
|
|
import bumblebee.engine
|
|
|
|
|
|
|
|
class Module(bumblebee.engine.Module):
|
|
|
|
def __init__(self, engine, config):
|
|
|
|
super(Module, self).__init__(engine, config,
|
|
|
|
bumblebee.output.Widget(full_text=self.brightness)
|
|
|
|
)
|
|
|
|
self._brightness = 0
|
|
|
|
|
|
|
|
step = self.parameter("step", 2)
|
|
|
|
|
|
|
|
engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP,
|
|
|
|
cmd="xbacklight +{}%".format(step))
|
|
|
|
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN,
|
|
|
|
cmd="xbacklight -{}%".format(step))
|
|
|
|
|
2016-12-11 11:37:24 +01:00
|
|
|
def brightness(self, widget):
|
2016-12-10 14:31:18 +01:00
|
|
|
return "{:03.0f}%".format(self._brightness)
|
|
|
|
|
|
|
|
def update(self, widgets):
|
|
|
|
self._brightness = float(bumblebee.util.execute("xbacklight -get"))
|
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|