From df0b3ccd36916a2e16700ba49477d21fb7c850bc Mon Sep 17 00:00:00 2001 From: JezerM Date: Mon, 13 Sep 2021 09:00:58 -0600 Subject: [PATCH] Added cursor theme support --- web-greeter/browser/browser.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web-greeter/browser/browser.py b/web-greeter/browser/browser.py index 4bc16b1..f7da972 100644 --- a/web-greeter/browser/browser.py +++ b/web-greeter/browser/browser.py @@ -28,6 +28,7 @@ # Standard lib +import re from browser.window import MainWindow import os from typing import ( @@ -83,6 +84,17 @@ ENABLED_SETTINGS = [ 'FocusOnNavigationEnabled', # Qt 5.11+ ] +def getDefaultCursor(): + cursor_theme = "" + file = open("/usr/share/icons/default/index.theme") + matched = re.search(r"Inherits=.*", file.read()) + file.close() + if not matched: + logger.error("Default cursor couldn't be get") + return "" + cursor_theme = matched.group().replace("Inherits=", "") + return cursor_theme + class Application: app: QApplication desktop: QDesktopWidget @@ -123,6 +135,9 @@ class Application: timeout = web_greeter_config["config"]["greeter"]["screensaver_timeout"] set_screensaver(timeout or 300) + cursor_theme = web_greeter_config["config"]["greeter"]["icon_theme"] + os.environ["XCURSOR_THEME"] = cursor_theme if cursor_theme != None else getDefaultCursor() + self.app.aboutToQuit.connect(self._before_exit) def _before_exit(self):