mirror of https://github.com/borgbase/vorta
Programmatically detect theme color (for macOS) (#150)
This commit is contained in:
parent
4c8363d5ad
commit
e2efcfc5a7
|
@ -11,7 +11,7 @@ import peewee as pw
|
|||
from playhouse.migrate import SqliteMigrator, migrate
|
||||
|
||||
from vorta.i18n import trans_late
|
||||
from vorta.utils import slugify
|
||||
from vorta.utils import slugify, uses_dark_mode
|
||||
|
||||
SCHEMA_VERSION = 10
|
||||
|
||||
|
@ -241,6 +241,8 @@ def init_db(con):
|
|||
# Create missing settings and update labels. Leave setting values untouched.
|
||||
for setting in get_misc_settings():
|
||||
s, created = SettingsModel.get_or_create(key=setting['key'], defaults=setting)
|
||||
if created and setting['key'] == "use_light_icon":
|
||||
s.value = bool(uses_dark_mode())
|
||||
s.label = setting['label']
|
||||
s.save()
|
||||
|
||||
|
|
|
@ -209,6 +209,19 @@ def set_tray_icon(tray, active=False):
|
|||
tray.setIcon(icon)
|
||||
|
||||
|
||||
def uses_dark_mode():
|
||||
"""
|
||||
This function detects if we are running in dark mode (e.g. macOS dark mode).
|
||||
|
||||
Returns None if the interface style cannot be determined, otherwise a boolean.
|
||||
"""
|
||||
if sys.platform == 'darwin':
|
||||
from Foundation import NSUserDefaults
|
||||
stdud = NSUserDefaults.standardUserDefaults()
|
||||
return stdud.stringForKey_("AppleInterfaceStyle") == "Dark"
|
||||
return None
|
||||
|
||||
|
||||
def open_app_at_startup(enabled=True):
|
||||
"""
|
||||
This function adds/removes the current app bundle from Login items in macOS
|
||||
|
|
Loading…
Reference in New Issue