|
|
@ -47,6 +47,7 @@ from . import ( |
|
|
|
session_to_dict, |
|
|
|
session_to_dict, |
|
|
|
user_to_dict, |
|
|
|
user_to_dict, |
|
|
|
battery_to_dict, |
|
|
|
battery_to_dict, |
|
|
|
|
|
|
|
debugLog |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
LightDMGreeter = LightDM.Greeter() |
|
|
|
LightDMGreeter = LightDM.Greeter() |
|
|
@ -62,9 +63,9 @@ def changeBrightness(self, method: str, quantity: int): |
|
|
|
if child.returncode == 1: |
|
|
|
if child.returncode == 1: |
|
|
|
raise ChildProcessError("xbacklight returned 1") |
|
|
|
raise ChildProcessError("xbacklight returned 1") |
|
|
|
except Exception as err: |
|
|
|
except Exception as err: |
|
|
|
print("[ERROR] Brightness:", err) |
|
|
|
debugLog("Brightness: {}".format(err), 4) |
|
|
|
finally: |
|
|
|
else: |
|
|
|
self.property_changed.emit() |
|
|
|
self.brightness_update.emit() |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def getBrightness(self): |
|
|
|
def getBrightness(self): |
|
|
@ -74,7 +75,7 @@ def getBrightness(self): |
|
|
|
level = subprocess.run(["xbacklight", "-get"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True) |
|
|
|
level = subprocess.run(["xbacklight", "-get"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True) |
|
|
|
return int(level.stdout) |
|
|
|
return int(level.stdout) |
|
|
|
except Exception as err: |
|
|
|
except Exception as err: |
|
|
|
print("[ERROR] Battery:", err) |
|
|
|
debugLog("Battery: {}".format(err), 4) |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
def updateBattery(self): |
|
|
|
def updateBattery(self): |
|
|
@ -90,7 +91,7 @@ def updateBattery(self): |
|
|
|
self._battery = int(level) |
|
|
|
self._battery = int(level) |
|
|
|
self._acpi = acpi.stdout |
|
|
|
self._acpi = acpi.stdout |
|
|
|
except Exception as err: |
|
|
|
except Exception as err: |
|
|
|
print("[ERROR] Battery: ", err) |
|
|
|
debugLog("Battery: {}".format(err), 4) |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.property_changed.emit() |
|
|
|
self.property_changed.emit() |
|
|
|
|
|
|
|
|
|
|
@ -104,6 +105,8 @@ class Greeter(BridgeObject): |
|
|
|
show_message = bridge.signal(str, LightDM.MessageType, arguments=('text', 'type')) |
|
|
|
show_message = bridge.signal(str, LightDM.MessageType, arguments=('text', 'type')) |
|
|
|
show_prompt = bridge.signal(str, LightDM.PromptType, arguments=('text', 'type')) |
|
|
|
show_prompt = bridge.signal(str, LightDM.PromptType, arguments=('text', 'type')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
brightness_update = bridge.signal() |
|
|
|
|
|
|
|
|
|
|
|
noop_signal = bridge.signal() |
|
|
|
noop_signal = bridge.signal() |
|
|
|
property_changed = bridge.signal() |
|
|
|
property_changed = bridge.signal() |
|
|
|
|
|
|
|
|
|
|
@ -149,6 +152,7 @@ class Greeter(BridgeObject): |
|
|
|
lambda greeter, msg, mtype: self._emit_signal(self.show_prompt, msg, mtype) |
|
|
|
lambda greeter, msg, mtype: self._emit_signal(self.show_prompt, msg, mtype) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _emit_signal(self, _signal, *args): |
|
|
|
def _emit_signal(self, _signal, *args): |
|
|
|
self.property_changed.emit() |
|
|
|
self.property_changed.emit() |
|
|
|
QTimer().singleShot(300, lambda: _signal.emit(*args)) |
|
|
|
QTimer().singleShot(300, lambda: _signal.emit(*args)) |
|
|
@ -173,7 +177,7 @@ class Greeter(BridgeObject): |
|
|
|
def batteryData(self): |
|
|
|
def batteryData(self): |
|
|
|
return battery_to_dict(self._acpi) |
|
|
|
return battery_to_dict(self._acpi) |
|
|
|
|
|
|
|
|
|
|
|
@bridge.prop(int, notify=property_changed) |
|
|
|
@bridge.prop(int, notify=brightness_update) |
|
|
|
def brightness(self): |
|
|
|
def brightness(self): |
|
|
|
return getBrightness(self) |
|
|
|
return getBrightness(self) |
|
|
|
|
|
|
|
|
|
|
@ -291,6 +295,10 @@ class Greeter(BridgeObject): |
|
|
|
LightDMGreeter.authenticate_as_guest() |
|
|
|
LightDMGreeter.authenticate_as_guest() |
|
|
|
self.property_changed.emit() |
|
|
|
self.property_changed.emit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bridge.method() |
|
|
|
|
|
|
|
def batteryUpdate(self): |
|
|
|
|
|
|
|
return updateBattery(self) |
|
|
|
|
|
|
|
|
|
|
|
@bridge.method(int) |
|
|
|
@bridge.method(int) |
|
|
|
def brightnessSet(self, quantity): |
|
|
|
def brightnessSet(self, quantity): |
|
|
|
return changeBrightness(self, "-set", quantity) |
|
|
|
return changeBrightness(self, "-set", quantity) |
|
|
@ -338,13 +346,11 @@ class Greeter(BridgeObject): |
|
|
|
|
|
|
|
|
|
|
|
@bridge.method(str, result=bool) |
|
|
|
@bridge.method(str, result=bool) |
|
|
|
def start_session(self, session): |
|
|
|
def start_session(self, session): |
|
|
|
return LightDMGreeter.start_session_sync(session) |
|
|
|
if not session.strip(): |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
return LightDMGreeter.start_session(session) |
|
|
|
|
|
|
|
|
|
|
|
@bridge.method(result=bool) |
|
|
|
@bridge.method(result=bool) |
|
|
|
def suspend(self): |
|
|
|
def suspend(self): |
|
|
|
return LightDM.suspend() |
|
|
|
return LightDM.suspend() |
|
|
|
|
|
|
|
|
|
|
|
@bridge.method() |
|
|
|
|
|
|
|
def batteryUpdate(self): |
|
|
|
|
|
|
|
return updateBattery(self) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|