Browse Source

Brightness control non blocking

sisyphus
JezerM 4 years ago
parent
commit
eb83bafa4c
  1. 18
      web-greeter/bridge/Greeter.py

18
web-greeter/bridge/Greeter.py

@ -28,6 +28,7 @@
# Standard Lib # Standard Lib
import subprocess import subprocess
import re import re
import threading
# 3rd-Party Libs # 3rd-Party Libs
import gi import gi
@ -53,7 +54,6 @@ from . import (
LightDMGreeter = LightDM.Greeter() LightDMGreeter = LightDM.Greeter()
LightDMUsers = LightDM.UserList() LightDMUsers = LightDM.UserList()
def changeBrightness(self, method: str, quantity: int): def changeBrightness(self, method: str, quantity: int):
if self._config.features.backlight["enabled"] != True: if self._config.features.backlight["enabled"] != True:
return return
@ -183,7 +183,9 @@ class Greeter(BridgeObject):
@brightness.setter @brightness.setter
def brightness(self, quantity): def brightness(self, quantity):
return changeBrightness(self, "-set", quantity) thread = threading.Thread(target=changeBrightness,
args=(self, "-set", quantity))
thread.start()
@bridge.prop(bool, notify=noop_signal) @bridge.prop(bool, notify=noop_signal)
def can_hibernate(self): def can_hibernate(self):
@ -305,15 +307,21 @@ class Greeter(BridgeObject):
@bridge.method(int) @bridge.method(int)
def brightnessSet(self, quantity): def brightnessSet(self, quantity):
return changeBrightness(self, "-set", quantity) thread = threading.Thread(target=changeBrightness,
args=(self, "-set", quantity))
thread.start()
@bridge.method(int) @bridge.method(int)
def brightnessIncrease(self, quantity): def brightnessIncrease(self, quantity):
return changeBrightness(self, "-inc", quantity) thread = threading.Thread(target=changeBrightness,
args=(self, "-inc", quantity))
thread.start()
@bridge.method(int) @bridge.method(int)
def brightnessDecrease(self, quantity): def brightnessDecrease(self, quantity):
return changeBrightness(self, "-dec", quantity) thread = threading.Thread(target=changeBrightness,
args=(self, "-dec", quantity))
thread.start()
@bridge.method() @bridge.method()
def cancel_authentication(self): def cancel_authentication(self):

Loading…
Cancel
Save