From eb83bafa4c565f06b0354d1d667e5cfeea74ef32 Mon Sep 17 00:00:00 2001 From: JezerM Date: Wed, 30 Jun 2021 10:01:07 -0600 Subject: [PATCH] Brightness control non blocking --- web-greeter/bridge/Greeter.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/web-greeter/bridge/Greeter.py b/web-greeter/bridge/Greeter.py index 32e2d5d..2e3a819 100644 --- a/web-greeter/bridge/Greeter.py +++ b/web-greeter/bridge/Greeter.py @@ -28,6 +28,7 @@ # Standard Lib import subprocess import re +import threading # 3rd-Party Libs import gi @@ -53,7 +54,6 @@ from . import ( LightDMGreeter = LightDM.Greeter() LightDMUsers = LightDM.UserList() - def changeBrightness(self, method: str, quantity: int): if self._config.features.backlight["enabled"] != True: return @@ -183,7 +183,9 @@ class Greeter(BridgeObject): @brightness.setter 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) def can_hibernate(self): @@ -305,15 +307,21 @@ class Greeter(BridgeObject): @bridge.method(int) def brightnessSet(self, quantity): - return changeBrightness(self, "-set", quantity) + thread = threading.Thread(target=changeBrightness, + args=(self, "-set", quantity)) + thread.start() @bridge.method(int) def brightnessIncrease(self, quantity): - return changeBrightness(self, "-inc", quantity) + thread = threading.Thread(target=changeBrightness, + args=(self, "-inc", quantity)) + thread.start() @bridge.method(int) def brightnessDecrease(self, quantity): - return changeBrightness(self, "-dec", quantity) + thread = threading.Thread(target=changeBrightness, + args=(self, "-dec", quantity)) + thread.start() @bridge.method() def cancel_authentication(self):