utility: create_startup_entry check link health

This commit is contained in:
Ilario Gelmetti 2023-07-07 11:32:31 +02:00
parent ae88ad3386
commit 9a4fce01e4
1 changed files with 15 additions and 11 deletions

View File

@ -400,18 +400,22 @@ def create_startup_entry():
"""
startup_dir_path = os.path.join(HOME_DIRECTORY, '.config/autostart')
startup_entry = os.path.join(startup_dir_path, 'io.github.slgobinath.SafeEyes.desktop')
# Create the folder if not exist
mkdir(startup_dir_path)
# Remove existing files
delete(startup_entry)
# Create the new startup entry
# a FileNotFoundError will get thrown if the startup symlink is missing or is broken
try:
os.symlink(SYSTEM_DESKTOP_FILE, startup_entry)
except OSError:
logging.error("Failed to create startup entry at %s" % startup_entry)
os.stat(startup_entry)
except FileNotFoundError:
# Create the folder if not exist
mkdir(startup_dir_path)
# Remove existing files
delete(startup_entry)
# Create the new startup entry
try:
os.symlink(SYSTEM_DESKTOP_FILE, startup_entry)
except OSError:
logging.error("Failed to create startup entry at %s" % startup_entry)
def initialize_platform():