mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 13:23:24 -07:00
Check if MacOS login item exists before adding
This commit is contained in:
parent
cac9e0b164
commit
e546689e01
1 changed files with 13 additions and 5 deletions
|
@ -108,9 +108,13 @@ def set_startup():
|
||||||
if plexpy.INSTALL_TYPE == 'macos':
|
if plexpy.INSTALL_TYPE == 'macos':
|
||||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(['osascript', '-e',
|
subprocess.Popen(['osascript',
|
||||||
'tell application "System Events" to make login item at end with properties '
|
'-e', 'tell application "System Events"',
|
||||||
'{path:"/Applications/Tautulli.app", hidden:false}'])
|
'-e', 'get the name of every login item',
|
||||||
|
'-e', 'if not exists login item "Tautulli" then '
|
||||||
|
'make login item at end with properties '
|
||||||
|
'{path:"/Applications/Tautulli.app", hidden:false}',
|
||||||
|
'-e', 'end tell'])
|
||||||
logger.info("Added Tautulli to MacOS login items.")
|
logger.info("Added Tautulli to MacOS login items.")
|
||||||
return True
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@ -119,8 +123,12 @@ def set_startup():
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(['osascript', '-e',
|
subprocess.Popen(['osascript',
|
||||||
'tell application "System Events" to delete login item "Tautulli"'])
|
'-e', 'tell application "System Events"',
|
||||||
|
'-e', 'get the name of every login item',
|
||||||
|
'-e', 'if exists login item "Tautulli" then '
|
||||||
|
'delete login item "Tautulli"',
|
||||||
|
'-e', 'end tell'])
|
||||||
logger.info("Removed Tautulli from MacOS login items.")
|
logger.info("Removed Tautulli from MacOS login items.")
|
||||||
return True
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue