mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Update system tray icon
This commit is contained in:
parent
00c9fc79f9
commit
cd5ed1d748
5 changed files with 39 additions and 32 deletions
|
@ -141,6 +141,7 @@ PLEX_SERVER_UP = None
|
||||||
TRACKER = None
|
TRACKER = None
|
||||||
|
|
||||||
WIN_SYS_TRAY_ICON = None
|
WIN_SYS_TRAY_ICON = None
|
||||||
|
MAC_SYS_TRAY_ICON = None
|
||||||
|
|
||||||
SYS_TIMEZONE = None
|
SYS_TIMEZONE = None
|
||||||
SYS_UTC_OFFSET = None
|
SYS_UTC_OFFSET = None
|
||||||
|
|
|
@ -638,7 +638,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'JWT_SECRET': (str, 'Advanced', ''),
|
'JWT_SECRET': (str, 'Advanced', ''),
|
||||||
'JWT_UPDATE_SECRET': (bool_int, 'Advanced', 0),
|
'JWT_UPDATE_SECRET': (bool_int, 'Advanced', 0),
|
||||||
'SYSTEM_ANALYTICS': (int, 'Advanced', 1),
|
'SYSTEM_ANALYTICS': (int, 'Advanced', 1),
|
||||||
'SYS_TRAY': (int, 'General', 1),
|
'SYS_TRAY_ICON': (int, 'General', 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
_BLACKLIST_KEYS = ['_APITOKEN', '_TOKEN', '_KEY', '_SECRET', '_PASSWORD', '_APIKEY', '_ID', '_HOOK']
|
_BLACKLIST_KEYS = ['_APITOKEN', '_TOKEN', '_KEY', '_SECRET', '_PASSWORD', '_APIKEY', '_ID', '_HOOK']
|
||||||
|
|
|
@ -35,28 +35,28 @@ else:
|
||||||
class MacOSSystemTray(object):
|
class MacOSSystemTray(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
self.image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
||||||
|
|
||||||
if plexpy.UPDATE_AVAILABLE:
|
if plexpy.UPDATE_AVAILABLE:
|
||||||
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||||
self.hover_text = common.PRODUCT + ' - Update Available!'
|
|
||||||
else:
|
else:
|
||||||
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||||
self.hover_text = common.PRODUCT
|
|
||||||
|
|
||||||
self.menu = [
|
self.menu = [
|
||||||
rumps.MenuItem('Open Tautulli', callback=self.tray_open),
|
rumps.MenuItem('Open Tautulli', callback=self.tray_open),
|
||||||
rumps.MenuItem('Start Tautulli at Login', callback=self.tray_startup),
|
rumps.MenuItem('Start Tautulli at Login', callback=self.tray_startup),
|
||||||
rumps.MenuItem('Check for Updates', callback=self.tray_check_update),
|
rumps.MenuItem('Check for Updates', callback=self.tray_check_update),
|
||||||
rumps.MenuItem('Update', callback=self.tray_update),
|
|
||||||
rumps.MenuItem('Restart', callback=self.tray_restart),
|
rumps.MenuItem('Restart', callback=self.tray_restart),
|
||||||
rumps.MenuItem('Quit', callback=self.tray_quit)
|
rumps.MenuItem('Quit', callback=self.tray_quit)
|
||||||
]
|
]
|
||||||
|
if not plexpy.FROZEN:
|
||||||
|
self.menu.insert(3, rumps.MenuItem('Update', callback=self.tray_update))
|
||||||
|
self.menu[1].state = plexpy.CONFIG.LAUNCH_STARTUP
|
||||||
|
|
||||||
self.tray_icon = None
|
self.tray_icon = rumps.App(common.PRODUCT, icon=self.icon, menu=self.menu, quit_button=None)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
logger.info("Launching MacOS system tray icon.")
|
logger.info("Launching MacOS system tray icon.")
|
||||||
try:
|
try:
|
||||||
self.tray_icon = rumps.App(common.PRODUCT, icon=self.icon, menu=self.menu, quit_button=None)
|
|
||||||
self.tray_icon.run()
|
self.tray_icon.run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Unable to launch system tray icon: %s." % e)
|
logger.error("Unable to launch system tray icon: %s." % e)
|
||||||
|
@ -65,8 +65,8 @@ class MacOSSystemTray(object):
|
||||||
rumps.quit_application()
|
rumps.quit_application()
|
||||||
|
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
#self.sys_tray_icon.update(**kwargs)
|
if 'icon' in kwargs:
|
||||||
pass
|
self.tray_icon.icon = kwargs['icon']
|
||||||
|
|
||||||
def tray_open(self, tray_icon):
|
def tray_open(self, tray_icon):
|
||||||
plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, plexpy.HTTP_PORT, plexpy.HTTP_ROOT)
|
plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, plexpy.HTTP_PORT, plexpy.HTTP_ROOT)
|
||||||
|
@ -81,9 +81,6 @@ class MacOSSystemTray(object):
|
||||||
def tray_update(self, tray_icon):
|
def tray_update(self, tray_icon):
|
||||||
if plexpy.UPDATE_AVAILABLE:
|
if plexpy.UPDATE_AVAILABLE:
|
||||||
plexpy.SIGNAL = 'update'
|
plexpy.SIGNAL = 'update'
|
||||||
else:
|
|
||||||
hover_text = common.PRODUCT + ' - No Update Available'
|
|
||||||
self.update(hover_text=hover_text)
|
|
||||||
|
|
||||||
def tray_restart(self, tray_icon):
|
def tray_restart(self, tray_icon):
|
||||||
plexpy.SIGNAL = 'restart'
|
plexpy.SIGNAL = 'restart'
|
||||||
|
@ -91,16 +88,22 @@ class MacOSSystemTray(object):
|
||||||
def tray_quit(self, tray_icon):
|
def tray_quit(self, tray_icon):
|
||||||
plexpy.SIGNAL = 'shutdown'
|
plexpy.SIGNAL = 'shutdown'
|
||||||
|
|
||||||
def change_tray_startup_icon(self):
|
def change_tray_update_icon(self):
|
||||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
if plexpy.UPDATE_AVAILABLE:
|
||||||
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||||
else:
|
else:
|
||||||
start_icon = None
|
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||||
#self.menu_options[2][1] = start_icon
|
self.update(icon=self.icon)
|
||||||
#self.update(menu_options=self.menu_options)
|
|
||||||
|
def change_tray_startup_icon(self):
|
||||||
|
self.menu[1].state = plexpy.CONFIG.LAUNCH_STARTUP
|
||||||
|
self.tray_icon.menu = self.menu
|
||||||
|
|
||||||
|
|
||||||
def set_startup():
|
def set_startup():
|
||||||
|
if plexpy.MAC_SYS_TRAY_ICON:
|
||||||
|
plexpy.MAC_SYS_TRAY_ICON.change_tray_startup_icon()
|
||||||
|
|
||||||
if plexpy.INSTALL_TYPE == 'macos':
|
if plexpy.INSTALL_TYPE == 'macos':
|
||||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -168,14 +168,9 @@ def check_update(scheduler=False, notify=False):
|
||||||
plexpy.UPDATE_AVAILABLE = False
|
plexpy.UPDATE_AVAILABLE = False
|
||||||
|
|
||||||
if plexpy.WIN_SYS_TRAY_ICON:
|
if plexpy.WIN_SYS_TRAY_ICON:
|
||||||
image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
plexpy.WIN_SYS_TRAY_ICON.change_tray_update_icon()
|
||||||
if plexpy.UPDATE_AVAILABLE:
|
elif plexpy.MAC_SYS_TRAY_ICON:
|
||||||
icon = os.path.join(image_dir, 'logo-circle-update.ico')
|
plexpy.MAC_SYS_TRAY_ICON.change_tray_update_icon()
|
||||||
hover_text = common.PRODUCT + ' - Update Available!'
|
|
||||||
else:
|
|
||||||
icon = os.path.join(image_dir, 'logo-circle.ico')
|
|
||||||
hover_text = common.PRODUCT + ' - No Update Available'
|
|
||||||
plexpy.WIN_SYS_TRAY_ICON.update(icon=icon, hover_text=hover_text)
|
|
||||||
|
|
||||||
|
|
||||||
def check_github(scheduler=False, notify=False):
|
def check_github(scheduler=False, notify=False):
|
||||||
|
|
|
@ -48,23 +48,22 @@ class WindowsSystemTray(object):
|
||||||
else:
|
else:
|
||||||
start_icon = None
|
start_icon = None
|
||||||
|
|
||||||
self.menu_options = [
|
self.menu = [
|
||||||
['Open Tautulli', None, self.tray_open, 'default'],
|
['Open Tautulli', None, self.tray_open, 'default'],
|
||||||
['', None, 'separator', None],
|
['', None, 'separator', None],
|
||||||
['Start Tautulli at Login', start_icon, self.tray_startup, None],
|
['Start Tautulli at Login', start_icon, self.tray_startup, None],
|
||||||
['', None, 'separator', None],
|
['', None, 'separator', None],
|
||||||
['Check for Updates', None, self.tray_check_update, None],
|
['Check for Updates', None, self.tray_check_update, None],
|
||||||
['Update', None, self.tray_update, None],
|
|
||||||
['Restart', None, self.tray_restart, None]
|
['Restart', None, self.tray_restart, None]
|
||||||
]
|
]
|
||||||
|
if not plexpy.FROZEN:
|
||||||
|
self.menu.insert(5, ['Update', None, self.tray_update, None])
|
||||||
|
|
||||||
self.tray_icon = None
|
self.tray_icon = SysTrayIcon(self.icon, self.hover_text, self.menu, on_quit=self.tray_quit)
|
||||||
self.start()
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
logger.info("Launching Windows system tray icon.")
|
logger.info("Launching Windows system tray icon.")
|
||||||
try:
|
try:
|
||||||
self.tray_icon = SysTrayIcon(self.icon, self.hover_text, self.menu_options, on_quit=self.tray_quit)
|
|
||||||
self.tray_icon.start()
|
self.tray_icon.start()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Unable to launch system tray icon: %s." % e)
|
logger.error("Unable to launch system tray icon: %s." % e)
|
||||||
|
@ -98,13 +97,22 @@ class WindowsSystemTray(object):
|
||||||
def tray_quit(self, tray_icon):
|
def tray_quit(self, tray_icon):
|
||||||
plexpy.SIGNAL = 'shutdown'
|
plexpy.SIGNAL = 'shutdown'
|
||||||
|
|
||||||
|
def change_tray_update_icon(self):
|
||||||
|
if plexpy.UPDATE_AVAILABLE:
|
||||||
|
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||||
|
self.hover_text = common.PRODUCT + ' - Update Available!'
|
||||||
|
else:
|
||||||
|
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||||
|
self.hover_text = common.PRODUCT + ' - No Update Available'
|
||||||
|
self.update(icon=self.icon, hover_text=self.hover_text)
|
||||||
|
|
||||||
def change_tray_startup_icon(self):
|
def change_tray_startup_icon(self):
|
||||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||||
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
||||||
else:
|
else:
|
||||||
start_icon = None
|
start_icon = None
|
||||||
self.menu_options[2][1] = start_icon
|
self.menu[2][1] = start_icon
|
||||||
self.update(menu_options=self.menu_options)
|
self.update(menu_options=self.menu)
|
||||||
|
|
||||||
|
|
||||||
def set_startup():
|
def set_startup():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue