| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -27,6 +27,7 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#  along with Web Greeter; If not, see <http://www.gnu.org/licenses/>. | 
					 | 
					 | 
					 | 
					#  along with Web Greeter; If not, see <http://www.gnu.org/licenses/>. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# Standard Lib | 
					 | 
					 | 
					 | 
					# Standard Lib | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from browser.error_prompt import Dialog | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import subprocess | 
					 | 
					 | 
					 | 
					import subprocess | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import threading | 
					 | 
					 | 
					 | 
					import threading | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -36,9 +37,11 @@ gi.require_version('LightDM', '1') | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from gi.repository import LightDM | 
					 | 
					 | 
					 | 
					from gi.repository import LightDM | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from browser.bridge import Bridge, BridgeObject | 
					 | 
					 | 
					 | 
					from browser.bridge import Bridge, BridgeObject | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from PyQt5.QtCore import QVariant, QTimer | 
					 | 
					 | 
					 | 
					from PyQt5.QtCore import QFileSystemWatcher, QVariant, QTimer | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from config import web_greeter_config | 
					 | 
					 | 
					 | 
					from config import web_greeter_config | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from utils.battery import Battery | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import globals | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# This Application | 
					 | 
					 | 
					 | 
					# This Application | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from . import ( | 
					 | 
					 | 
					 | 
					from . import ( | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -56,19 +59,52 @@ LightDMGreeter = LightDM.Greeter() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					LightDMUsers = LightDM.UserList() | 
					 | 
					 | 
					 | 
					LightDMUsers = LightDM.UserList() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					def changeBrightness(self, method: str, quantity: int): | 
					 | 
					 | 
					 | 
					def changeBrightness(method: str, quantity: int = None): | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if self._config["features"]["backlight"]["enabled"] != True: | 
					 | 
					 | 
					 | 
					    backlight = web_greeter_config["config"]["features"]["backlight"] | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not backlight["enabled"]: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return | 
					 | 
					 | 
					 | 
					        return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not quantity: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        quantity = backlight["value"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    try: | 
					 | 
					 | 
					 | 
					    try: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        steps = self._config["features"]["backlight"]["steps"] | 
					 | 
					 | 
					 | 
					        steps = backlight["steps"] | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        child = subprocess.run(["xbacklight", method, str(quantity), "-steps", str(steps)]) | 
					 | 
					 | 
					 | 
					        child = subprocess.run(["xbacklight", method, str(quantity), "-steps", str(steps)]) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        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: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        logger.error("Brightness: {}".format(err)) | 
					 | 
					 | 
					 | 
					        logger.error("Brightness: {}".format(err)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    else: | 
					 | 
					 | 
					 | 
					    else: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.brightness_update.emit() | 
					 | 
					 | 
					 | 
					        if globals.greeter: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            globals.greeter.greeter.brightness_update.emit() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					def increaseBrightness(quantity: int = None): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    backlight = web_greeter_config["config"]["features"]["backlight"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not backlight["enabled"]: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not quantity: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        quantity = backlight["value"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread = threading.Thread(target=changeBrightness, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                              args=("-inc", quantity)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread.start() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					def decreaseBrightness(quantity: int = None): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    backlight = web_greeter_config["config"]["features"]["backlight"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not backlight["enabled"]: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not quantity: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        quantity = backlight["value"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread = threading.Thread(target=changeBrightness, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                              args=("-dec", quantity)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread.start() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					def setBrightness(quantity: int = None): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    backlight = web_greeter_config["config"]["features"]["backlight"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not backlight["enabled"]: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if not quantity: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        quantity = backlight["value"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread = threading.Thread(target=changeBrightness, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                              args=("-set", quantity)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    thread.start() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					def getBrightness(self): | 
					 | 
					 | 
					 | 
					def getBrightness(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if self._config["features"]["backlight"]["enabled"] != True: | 
					 | 
					 | 
					 | 
					    if self._config["features"]["backlight"]["enabled"] != True: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -106,13 +142,23 @@ class Greeter(BridgeObject): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self._shared_data_directory = '' | 
					 | 
					 | 
					 | 
					        self._shared_data_directory = '' | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self._themes_directory = web_greeter_config["app"]["theme_dir"] | 
					 | 
					 | 
					 | 
					        self._themes_directory = web_greeter_config["app"]["theme_dir"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # if self._config.features.battery == True: | 
					 | 
					 | 
					 | 
					        if self._config["features"]["battery"]: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            # self._battery = battery.Battery() | 
					 | 
					 | 
					 | 
					            self._battery = Battery() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        try: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            LightDMGreeter.connect_to_daemon_sync() | 
					 | 
					 | 
					 | 
					            LightDMGreeter.connect_to_daemon_sync() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        except Exception as err: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            logger.error(err) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            dia = Dialog(title="An error ocurred", | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                         message="Detected a problem that could interfere with the system login process", | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                         detail="LightDM: {0}\nYou can continue without major problems, but you won't be able to log in".format(err), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                         buttons=["Okay"]) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            dia.exec() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            pass | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self._connect_signals() | 
					 | 
					 | 
					 | 
					        self._connect_signals() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self._determine_shared_data_directory_path() | 
					 | 
					 | 
					 | 
					        self._determine_shared_data_directory_path() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        logger.debug("LightDM API connected") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def _determine_shared_data_directory_path(self): | 
					 | 
					 | 
					 | 
					    def _determine_shared_data_directory_path(self): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        user = LightDMUsers.get_users()[0] | 
					 | 
					 | 
					 | 
					        user = LightDMUsers.get_users()[0] | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -174,9 +220,7 @@ class Greeter(BridgeObject): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @brightness.setter | 
					 | 
					 | 
					 | 
					    @brightness.setter | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def brightness(self, quantity): | 
					 | 
					 | 
					 | 
					    def brightness(self, quantity): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread = threading.Thread(target=changeBrightness, | 
					 | 
					 | 
					 | 
					        setBrightness(quantity) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                  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,21 +349,15 @@ class Greeter(BridgeObject): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def brightnessSet(self, quantity): | 
					 | 
					 | 
					 | 
					    def brightnessSet(self, quantity): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread = threading.Thread(target=changeBrightness, | 
					 | 
					 | 
					 | 
					        setBrightness(quantity) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                  args=(self, "-set", quantity)) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread.start() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def brightnessIncrease(self, quantity): | 
					 | 
					 | 
					 | 
					    def brightnessIncrease(self, quantity): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread = threading.Thread(target=changeBrightness, | 
					 | 
					 | 
					 | 
					        increaseBrightness(quantity) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                  args=(self, "-inc", quantity)) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread.start() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
					 | 
					 | 
					 | 
					    @Bridge.method(int) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def brightnessDecrease(self, quantity): | 
					 | 
					 | 
					 | 
					    def brightnessDecrease(self, quantity): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread = threading.Thread(target=changeBrightness, | 
					 | 
					 | 
					 | 
					        decreaseBrightness(quantity) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                  args=(self, "-dec", quantity)) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        thread.start() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Bridge.method() | 
					 | 
					 | 
					 | 
					    @Bridge.method() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    def cancel_authentication(self): | 
					 | 
					 | 
					 | 
					    def cancel_authentication(self): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |