mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-30 03:28:31 -07:00
Add to MacOS login item when installed as pkg
This commit is contained in:
parent
2efd81dc6a
commit
7047ac8007
2 changed files with 66 additions and 42 deletions
|
@ -16,6 +16,7 @@
|
|||
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import plistlib
|
||||
|
||||
|
@ -29,6 +30,29 @@ else:
|
|||
|
||||
|
||||
def set_startup():
|
||||
if plexpy.INSTALL_TYPE == 'macos':
|
||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||
try:
|
||||
subprocess.Popen(['osascript', '-e',
|
||||
'tell application "System Events" to make login item at end with properties '
|
||||
'{path:"~/Applications/Tautulli.app", hidden:false}'])
|
||||
logger.info("Added Tautulli to MacOS login items.")
|
||||
return True
|
||||
except OSError as e:
|
||||
logger.error("Failed to add Tautulli to MacOS login items: %s", e)
|
||||
return False
|
||||
|
||||
else:
|
||||
try:
|
||||
subprocess.Popen(['osascript', '-e',
|
||||
'tell application "System Events" to delete login item "Tautulli"'])
|
||||
logger.info("Removed Tautulli from MacOS login items.")
|
||||
return True
|
||||
except OSError as e:
|
||||
logger.error("Failed to remove Tautulli from MacOS login items: %s", e)
|
||||
return False
|
||||
|
||||
else:
|
||||
launch_agents = os.path.join(os.path.expanduser('~'), 'Library/LaunchAgents')
|
||||
plist_file = 'com.Tautulli.Tautulli.plist'
|
||||
plist_file_path = os.path.join(launch_agents, plist_file)
|
||||
|
@ -64,14 +88,14 @@ def set_startup():
|
|||
logger.error("Failed to create MacOS system startup plist file: %s", e)
|
||||
return False
|
||||
|
||||
logger.info("Added Tautulli to MacOS system startup.")
|
||||
logger.info("Added Tautulli to MacOS system startup launch agents.")
|
||||
return True
|
||||
|
||||
else:
|
||||
try:
|
||||
if os.path.isfile(plist_file_path):
|
||||
os.remove(plist_file_path)
|
||||
logger.info("Removed Tautulli from MacOS system startup.")
|
||||
logger.info("Removed Tautulli from MacOS system startup launch agents.")
|
||||
return True
|
||||
except OSError as e:
|
||||
logger.error("Failed to delete MacOS system startup plist file: %s", e)
|
||||
|
|
|
@ -115,7 +115,7 @@ def set_startup():
|
|||
registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_WRITE)
|
||||
winreg.SetValueEx(registry_key, common.PRODUCT, 0, winreg.REG_SZ, cmd)
|
||||
winreg.CloseKey(registry_key)
|
||||
logger.info("Added Tautulli to Windows system startup.")
|
||||
logger.info("Added Tautulli to Windows system startup registry key.")
|
||||
return True
|
||||
except WindowsError as e:
|
||||
logger.error("Failed to create Windows system startup registry key: %s", e)
|
||||
|
@ -126,7 +126,7 @@ def set_startup():
|
|||
registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_ALL_ACCESS)
|
||||
winreg.DeleteValue(registry_key, common.PRODUCT)
|
||||
winreg.CloseKey(registry_key)
|
||||
logger.info("Removed Tautulli from Windows system startup.")
|
||||
logger.info("Removed Tautulli from Windows system startup registry key.")
|
||||
return True
|
||||
except WindowsError as e:
|
||||
logger.error("Failed to delete Windows system startup registry key: %s", e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue