Browse Source

Xlib display error now catched, and fixed window size when no window manager

sisyphus
JezerM 3 years ago
parent
commit
57df0113ca
No known key found for this signature in database
GPG Key ID: 66BBC5D01388C6B5
  1. 9
      web-greeter/browser/browser.py
  2. 19
      web-greeter/utils/screensaver.py

9
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)

19
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"])

Loading…
Cancel
Save