mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -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
|
||||
|
||||
WIN_SYS_TRAY_ICON = None
|
||||
MAC_SYS_TRAY_ICON = None
|
||||
|
||||
SYS_TIMEZONE = None
|
||||
SYS_UTC_OFFSET = None
|
||||
|
|
|
@ -638,7 +638,7 @@ _CONFIG_DEFINITIONS = {
|
|||
'JWT_SECRET': (str, 'Advanced', ''),
|
||||
'JWT_UPDATE_SECRET': (bool_int, 'Advanced', 0),
|
||||
'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']
|
||||
|
|
|
@ -35,28 +35,28 @@ else:
|
|||
class MacOSSystemTray(object):
|
||||
def __init__(self):
|
||||
self.image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
||||
|
||||
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
|
||||
|
||||
self.menu = [
|
||||
rumps.MenuItem('Open Tautulli', callback=self.tray_open),
|
||||
rumps.MenuItem('Start Tautulli at Login', callback=self.tray_startup),
|
||||
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('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):
|
||||
logger.info("Launching MacOS system tray icon.")
|
||||
try:
|
||||
self.tray_icon = rumps.App(common.PRODUCT, icon=self.icon, menu=self.menu, quit_button=None)
|
||||
self.tray_icon.run()
|
||||
except Exception as e:
|
||||
logger.error("Unable to launch system tray icon: %s." % e)
|
||||
|
@ -65,8 +65,8 @@ class MacOSSystemTray(object):
|
|||
rumps.quit_application()
|
||||
|
||||
def update(self, **kwargs):
|
||||
#self.sys_tray_icon.update(**kwargs)
|
||||
pass
|
||||
if 'icon' in kwargs:
|
||||
self.tray_icon.icon = kwargs['icon']
|
||||
|
||||
def tray_open(self, tray_icon):
|
||||
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):
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
plexpy.SIGNAL = 'update'
|
||||
else:
|
||||
hover_text = common.PRODUCT + ' - No Update Available'
|
||||
self.update(hover_text=hover_text)
|
||||
|
||||
def tray_restart(self, tray_icon):
|
||||
plexpy.SIGNAL = 'restart'
|
||||
|
@ -91,16 +88,22 @@ class MacOSSystemTray(object):
|
|||
def tray_quit(self, tray_icon):
|
||||
plexpy.SIGNAL = 'shutdown'
|
||||
|
||||
def change_tray_startup_icon(self):
|
||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
||||
def change_tray_update_icon(self):
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||
else:
|
||||
start_icon = None
|
||||
#self.menu_options[2][1] = start_icon
|
||||
#self.update(menu_options=self.menu_options)
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||
self.update(icon=self.icon)
|
||||
|
||||
def change_tray_startup_icon(self):
|
||||
self.menu[1].state = plexpy.CONFIG.LAUNCH_STARTUP
|
||||
self.tray_icon.menu = self.menu
|
||||
|
||||
|
||||
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.CONFIG.LAUNCH_STARTUP:
|
||||
try:
|
||||
|
|
|
@ -168,14 +168,9 @@ def check_update(scheduler=False, notify=False):
|
|||
plexpy.UPDATE_AVAILABLE = False
|
||||
|
||||
if plexpy.WIN_SYS_TRAY_ICON:
|
||||
image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
icon = os.path.join(image_dir, 'logo-circle-update.ico')
|
||||
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)
|
||||
plexpy.WIN_SYS_TRAY_ICON.change_tray_update_icon()
|
||||
elif plexpy.MAC_SYS_TRAY_ICON:
|
||||
plexpy.MAC_SYS_TRAY_ICON.change_tray_update_icon()
|
||||
|
||||
|
||||
def check_github(scheduler=False, notify=False):
|
||||
|
|
|
@ -48,23 +48,22 @@ class WindowsSystemTray(object):
|
|||
else:
|
||||
start_icon = None
|
||||
|
||||
self.menu_options = [
|
||||
self.menu = [
|
||||
['Open Tautulli', None, self.tray_open, 'default'],
|
||||
['', None, 'separator', None],
|
||||
['Start Tautulli at Login', start_icon, self.tray_startup, None],
|
||||
['', None, 'separator', None],
|
||||
['Check for Updates', None, self.tray_check_update, None],
|
||||
['Update', None, self.tray_update, 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.start()
|
||||
self.tray_icon = SysTrayIcon(self.icon, self.hover_text, self.menu, on_quit=self.tray_quit)
|
||||
|
||||
def start(self):
|
||||
logger.info("Launching Windows system tray icon.")
|
||||
try:
|
||||
self.tray_icon = SysTrayIcon(self.icon, self.hover_text, self.menu_options, on_quit=self.tray_quit)
|
||||
self.tray_icon.start()
|
||||
except Exception as e:
|
||||
logger.error("Unable to launch system tray icon: %s." % e)
|
||||
|
@ -98,13 +97,22 @@ class WindowsSystemTray(object):
|
|||
def tray_quit(self, tray_icon):
|
||||
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):
|
||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
||||
else:
|
||||
start_icon = None
|
||||
self.menu_options[2][1] = start_icon
|
||||
self.update(menu_options=self.menu_options)
|
||||
self.menu[2][1] = start_icon
|
||||
self.update(menu_options=self.menu)
|
||||
|
||||
|
||||
def set_startup():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue