Merge pull request #398 from donfranio/mod-brightness-consider-brightnessctl
Mod brightness consider brightnessctl
This commit is contained in:
commit
4db9c714bb
1 changed files with 14 additions and 11 deletions
|
@ -13,26 +13,29 @@ import bumblebee.input
|
||||||
import bumblebee.output
|
import bumblebee.output
|
||||||
import bumblebee.engine
|
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=self.brightness)
|
bumblebee.output.Widget(full_text=self.brightness))
|
||||||
)
|
|
||||||
self._brightness = 0
|
self._brightness = 0
|
||||||
|
|
||||||
self._device_path = self.parameter("device_path", "/sys/class/backlight/intel_backlight")
|
self._device_path = 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"):
|
||||||
engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP,
|
self.register_cmd(engine, "light -A {}%".format(step),
|
||||||
cmd="light -A {}%".format(step))
|
"light -U {}%".format(step))
|
||||||
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN,
|
elif bumblebee.util.which("brightnessctl"):
|
||||||
cmd="light -U {}%".format(step))
|
self.register_cmd(engine, "brightnessctl s {}%+".format(step),
|
||||||
|
"brightnessctl s {}%-".format(step))
|
||||||
else:
|
else:
|
||||||
engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP,
|
self.register_cmd(engine, "xbacklight +{}%".format(step),
|
||||||
cmd="xbacklight +{}%".format(step))
|
"xbacklight -{}%".format(step))
|
||||||
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN,
|
|
||||||
cmd="xbacklight -{}%".format(step))
|
def register_cmd(self, engine, upCmd, downCmd):
|
||||||
|
engine.input.register_callback(self, button=bumblebee.input.WHEEL_UP, cmd=upCmd)
|
||||||
|
engine.input.register_callback(self, button=bumblebee.input.WHEEL_DOWN, cmd=downCmd)
|
||||||
|
|
||||||
def brightness(self, widget):
|
def brightness(self, widget):
|
||||||
if isinstance(self._brightness, float):
|
if isinstance(self._brightness, float):
|
||||||
|
@ -46,7 +49,7 @@ class Module(bumblebee.engine.Module):
|
||||||
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"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue