fix missing stylesheet

This commit is contained in:
deltragon 2024-07-25 22:39:08 +02:00
parent de5e7ea5c2
commit bd600d0994
2 changed files with 13 additions and 5 deletions

View File

@ -93,6 +93,7 @@ def main():
utility.initialize_logging(args.debug) utility.initialize_logging(args.debug)
utility.initialize_platform() utility.initialize_platform()
config = Config() config = Config()
utility.create_user_stylesheet_if_missing()
if __running(): if __running():
logging.info("Safe Eyes is already running") logging.info("Safe Eyes is already running")

View File

@ -365,21 +365,28 @@ def initialize_safeeyes():
# Remove the ~/.config/safeeyes/safeeyes.json file # Remove the ~/.config/safeeyes/safeeyes.json file
delete(CONFIG_FILE_PATH) delete(CONFIG_FILE_PATH)
# Create the XDG_CONFIG_HOME(or ~/.config)/safeeyes/style directory if not os.path.isdir(CONFIG_DIRECTORY):
mkdir(STYLE_SHEET_DIRECTORY) mkdir(CONFIG_DIRECTORY)
# Copy the safeeyes.json # Copy the safeeyes.json
shutil.copy2(SYSTEM_CONFIG_FILE_PATH, CONFIG_FILE_PATH) shutil.copy2(SYSTEM_CONFIG_FILE_PATH, CONFIG_FILE_PATH)
os.chmod(CONFIG_FILE_PATH, 0o777) 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 # Copy the new style sheet
if not os.path.isfile(STYLE_SHEET_PATH): if not os.path.isfile(STYLE_SHEET_PATH):
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH) shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
os.chmod(STYLE_SHEET_PATH, 0o777) 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): def create_startup_entry(force=False):
""" """
Create start up entry. Create start up entry.