From bd600d099489091d0582d9d47e8ae8ddf5f3ad38 Mon Sep 17 00:00:00 2001 From: deltragon Date: Thu, 25 Jul 2024 22:39:08 +0200 Subject: [PATCH] fix missing stylesheet --- safeeyes/__main__.py | 1 + safeeyes/utility.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/safeeyes/__main__.py b/safeeyes/__main__.py index a3c1171..61ec8a8 100755 --- a/safeeyes/__main__.py +++ b/safeeyes/__main__.py @@ -93,6 +93,7 @@ def main(): utility.initialize_logging(args.debug) utility.initialize_platform() config = Config() + utility.create_user_stylesheet_if_missing() if __running(): logging.info("Safe Eyes is already running") diff --git a/safeeyes/utility.py b/safeeyes/utility.py index 022d63c..80cfe40 100644 --- a/safeeyes/utility.py +++ b/safeeyes/utility.py @@ -365,21 +365,28 @@ def initialize_safeeyes(): # Remove the ~/.config/safeeyes/safeeyes.json file delete(CONFIG_FILE_PATH) - # Create the XDG_CONFIG_HOME(or ~/.config)/safeeyes/style directory - mkdir(STYLE_SHEET_DIRECTORY) + if not os.path.isdir(CONFIG_DIRECTORY): + mkdir(CONFIG_DIRECTORY) # Copy the safeeyes.json shutil.copy2(SYSTEM_CONFIG_FILE_PATH, CONFIG_FILE_PATH) os.chmod(CONFIG_FILE_PATH, 0o777) + create_user_stylesheet_if_missing() + + # initialize_safeeyes gets called when the configuration file is not present, which happens just after installation or manual deletion of .config/safeeyes/safeeyes.json file. In these cases, we want to force the creation of a startup entry + create_startup_entry(force=True) + +def create_user_stylesheet_if_missing(): + # Create the XDG_CONFIG_HOME(or ~/.config)/safeeyes/style directory + if not os.path.isdir(STYLE_SHEET_DIRECTORY): + mkdir(STYLE_SHEET_DIRECTORY) + # Copy the new style sheet if not os.path.isfile(STYLE_SHEET_PATH): shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH) os.chmod(STYLE_SHEET_PATH, 0o777) - # initialize_safeeyes gets called when the configuration file is not present, which happens just after installation or manual deletion of .config/safeeyes/safeeyes.json file. In these cases, we want to force the creation of a startup entry - create_startup_entry(force=True) - def create_startup_entry(force=False): """ Create start up entry.