diff --git a/web-greeter/browser/browser.py b/web-greeter/browser/browser.py index f7da972..5a52ca9 100644 --- a/web-greeter/browser/browser.py +++ b/web-greeter/browser/browser.py @@ -52,7 +52,7 @@ from browser.interceptor import QtUrlRequestInterceptor from logger import logger from config import web_greeter_config from bridge import Greeter, Config, ThemeUtils -from utils.screensaver import reset_screensaver, set_screensaver +from utils.screensaver import reset_screensaver, set_screensaver, init_display import resources # Typing Helpers @@ -121,6 +121,11 @@ class Application: if web_greeter_config["app"]["frame"]: self._init_menu_bar() + screen_size = self.desktop.screen().size() + + self.window.setBaseSize(screen_size) + self.window.resize(screen_size) + state = self.states['NORMAL'] if web_greeter_config["app"]["fullscreen"]: state = self.states["FULLSCREEN"] @@ -132,6 +137,8 @@ class Application: self.window.setCursor(Qt.CursorShape.ArrowCursor) + init_display() + timeout = web_greeter_config["config"]["greeter"]["screensaver_timeout"] set_screensaver(timeout or 300) diff --git a/web-greeter/utils/screensaver.py b/web-greeter/utils/screensaver.py index 34d8630..6d339f8 100644 --- a/web-greeter/utils/screensaver.py +++ b/web-greeter/utils/screensaver.py @@ -3,12 +3,21 @@ from Xlib.display import Display saved_data: dict[str, int] saved = False +available = False -display = Display() +display = None + +def init_display(): + global display, available + try: + display = Display() + available = True + except Exception as err: + logger.error(f"Xlib error: {err}") def set_screensaver(timeout: int): - global saved_data, saved - if saved: + global saved_data, saved, available, display + if saved or not available: return display.sync() data: dict[str, int] = display.get_screen_saver()._data or {} @@ -20,8 +29,8 @@ def set_screensaver(timeout: int): logger.debug("Screensaver timeout set") def reset_screensaver(): - global saved_data, saved - if not saved: + global saved_data, saved, available, display + if not saved or not available: return display.sync() display.set_screen_saver(saved_data["timeout"], saved_data["interval"], saved_data["prefer_blanking"], saved_data["allow_exposures"])