From ab1034164485924496aa0a73728f04698856522b Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 12 May 2023 17:44:22 +0200 Subject: [PATCH 01/35] Updated dependencies --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index ae0a672d..bb20c0c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -numpy==1.23.5 -psutil==5.9.4 -PySide6==6.4.1 -PySide6-Addons==6.4.1 -PySide6-Essentials==6.4.1 +numpy==1.24.2 +psutil==5.9.5 +PySide6==6.5.0 +PySide6-Addons==6.5.0 +PySide6-Essentials==6.5.0 python-dateutil==2.8.2 -shiboken6==6.4.1 +shiboken6==6.5.0 six==1.16.0 suntime==1.2.5 -systemd-python==234 +systemd-python==235 From d04557c503a490767ef2d0b92a135b68cb5574c8 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 31 Oct 2022 22:46:59 +0100 Subject: [PATCH 02/35] Add initial support for Mate --- src/config.py | 2 ++ src/meta.py | 1 + src/plugins/gtk.py | 9 +++++++++ src/plugins/icons.py | 18 ++++++++++++++++++ src/plugins/system.py | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 src/plugins/icons.py diff --git a/src/config.py b/src/config.py index fca6e507..ad13e713 100755 --- a/src/config.py +++ b/src/config.py @@ -153,6 +153,8 @@ def get_desktop() -> Desktop: return Desktop.KDE case 'xfce': return Desktop.XFCE + case 'mate': + return Desktop.MATE case 'sway' | 'hyprland': return Desktop.GNOME case _: diff --git a/src/meta.py b/src/meta.py index cc577c01..d824f315 100644 --- a/src/meta.py +++ b/src/meta.py @@ -14,6 +14,7 @@ class Desktop(Enum): GNOME = 'gnome' XFCE = 'xfce' UNKNOWN = 'unknown' + MATE = 'mate' class PluginKey(Enum): diff --git a/src/plugins/gtk.py b/src/plugins/gtk.py index 61594451..2c9916a4 100755 --- a/src/plugins/gtk.py +++ b/src/plugins/gtk.py @@ -26,6 +26,8 @@ def __init__(self, desktop: Desktop): if not self.strategy.available: print('You need to install an extension for gnome to use it. \n' 'You can get it from here: https://extensions.gnome.org/extension/19/user-themes/') + case Desktop.MATE: + super().__init__(_Mate()) case Desktop.XFCE: super().__init__(_Xfce()) case _: @@ -83,3 +85,10 @@ def __init__(self): super(_Xfce, self).__init__(['xfconf-query', '-c', 'xsettings', '-p', '/Net/ThemeName', '-s', '{theme}']) self.theme_light = 'Adwaita' self.theme_dark = 'Adwaita-dark' + + +class _Mate(PluginCommandline): + def __init__(self): + super().__init__(['dconf write', '/org/mate/desktop/interface/gtk-theme', '"\'{theme}\'"']) + self.theme_light = 'Yaru' + self.theme_dark = 'Yaru-dark' diff --git a/src/plugins/icons.py b/src/plugins/icons.py new file mode 100644 index 00000000..1d1b1a8b --- /dev/null +++ b/src/plugins/icons.py @@ -0,0 +1,18 @@ +from meta import Desktop +from src.plugins._plugin import PluginDesktopDependent, PluginCommandline + + +class Icons(PluginDesktopDependent): + def __init__(self, desktop: Desktop): + match desktop: + case Desktop.MATE: + super().__init__(_Mate()) + case _: + super().__init__(None) + + +class _Mate(PluginCommandline): + def __init__(self): + super().__init__(['dconf', 'write', '/org/mate/desktop/interface/icon-theme', '"\'{theme}\'"']) + self.theme_light = 'Yaru' + self.theme_dark = 'Yaru-dark' diff --git a/src/plugins/system.py b/src/plugins/system.py index ddd0ba4e..0fcb256a 100644 --- a/src/plugins/system.py +++ b/src/plugins/system.py @@ -3,6 +3,8 @@ import subprocess import pwd import os +from configparser import ConfigParser +from pathlib import Path from PySide6.QtCore import QLocale @@ -35,6 +37,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Kde()) case Desktop.GNOME: super().__init__(_Gnome()) + case Desktop.MATE: + super().__init__(_Mate()) case _: super().__init__(None) @@ -129,3 +133,36 @@ def available_themes(self) -> dict: self.translations[long_name] = long_name return self.translations + + +class _Mate(PluginCommandline): + theme_directories = ['/usr/share/themes', f'{Path.home()}/.themes'] + + def __init__(self): + super().__init__(['dconf', 'write', '/org/mate/marco/general/theme', '"\'{theme}\'"']) + self.theme_light = 'Yaru' + self.theme_dark = 'Yaru-dark' + + @property + def available_themes(self) -> dict: + themes = [] + + for directory in self.theme_directories: + if not os.path.isdir(directory): + continue + + with os.scandir(directory) as entries: + for d in entries: + index = d.name + '/index.theme' + if not os.path.isfile(index): + continue + + config = ConfigParser() + config.read(index) + try: + theme = config['X-GNOME-Metatheme']['MetacityTheme'] + themes.append(theme) + except KeyError: + continue + + return {} From a595acac8d2927c4381e586423aeac6f45958b1f Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 31 Oct 2022 23:09:54 +0100 Subject: [PATCH 03/35] Make available test more modular --- src/plugins/_plugin.py | 16 ++++++++++++---- src/plugins/gtk.py | 4 ++++ src/plugins/icons.py | 4 ++++ src/plugins/system.py | 19 ++++++------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/plugins/_plugin.py b/src/plugins/_plugin.py index 430e2fc0..4d8d535f 100644 --- a/src/plugins/_plugin.py +++ b/src/plugins/_plugin.py @@ -144,14 +144,22 @@ def insert_theme(self, theme: str) -> list: return command - @property - def available(self) -> bool: - # Runs the first entry in the command list with --help + @staticmethod + def check_command(command) -> bool: + # Returns true if command execution succeeds try: - return subprocess.run([self.command[0], '--help'], stdout=subprocess.DEVNULL).returncode == 0 + subprocess.check_call(command, stdout=subprocess.DEVNULL) + return True except FileNotFoundError: # if no such command is available, the plugin is not available return False + except subprocess.CalledProcessError: + # command execution failed + return False + + @property + def available(self): + return self.check_command([self.command[0], '--help']) class PluginDesktopDependent(Plugin): diff --git a/src/plugins/gtk.py b/src/plugins/gtk.py index 2c9916a4..e929bf16 100755 --- a/src/plugins/gtk.py +++ b/src/plugins/gtk.py @@ -92,3 +92,7 @@ def __init__(self): super().__init__(['dconf write', '/org/mate/desktop/interface/gtk-theme', '"\'{theme}\'"']) self.theme_light = 'Yaru' self.theme_dark = 'Yaru-dark' + + @property + def available(self) -> bool: + return self.check_command(['dconf', 'help']) diff --git a/src/plugins/icons.py b/src/plugins/icons.py index 1d1b1a8b..367e8f98 100644 --- a/src/plugins/icons.py +++ b/src/plugins/icons.py @@ -16,3 +16,7 @@ def __init__(self): super().__init__(['dconf', 'write', '/org/mate/desktop/interface/icon-theme', '"\'{theme}\'"']) self.theme_light = 'Yaru' self.theme_dark = 'Yaru-dark' + + @property + def available(self): + return self.check_command(['dconf', 'help']) diff --git a/src/plugins/system.py b/src/plugins/system.py index 0fcb256a..85069d7a 100644 --- a/src/plugins/system.py +++ b/src/plugins/system.py @@ -15,19 +15,9 @@ def test_gnome_availability(command) -> bool: - # Runs the first entry in the command list with --help - try: - # if not available, you might want to run https://gist.github.com/atiensivu/fcc3183e9a6fd74ec1a283e3b9ad05f0 - # or you have to install that extension - process = subprocess.run( - [command[0], 'get', command[2], command[3]], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL - ) - return process.returncode == 0 - except FileNotFoundError: - # if no such command is available, the plugin is not available - return False + return PluginCommandline.check_command( + [command[0], 'get', command[2], command[3]] + ) class System(PluginDesktopDependent): @@ -166,3 +156,6 @@ def available_themes(self) -> dict: continue return {} + + def available(self): + return self.check_command(['dconf', 'help']) From d9447a2b5477acc9af3c1e7efa833c2d8ac09b66 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 31 Oct 2022 23:18:44 +0100 Subject: [PATCH 04/35] Various fixes --- src/plugins/__init__.py | 3 ++- src/plugins/gtk.py | 2 +- src/plugins/icons.py | 4 ++-- src/plugins/system.py | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/__init__.py b/src/plugins/__init__.py index 0c682635..4fae012f 100755 --- a/src/plugins/__init__.py +++ b/src/plugins/__init__.py @@ -1,5 +1,5 @@ from src.meta import Desktop -from src.plugins import system, colors, gtk, kvantum, wallpaper, custom +from src.plugins import system, colors, gtk, icons, kvantum, wallpaper, custom from src.plugins import firefox, brave, gedit, only_office from src.plugins import vscode, atom, konsole from src.plugins import sound, notify @@ -14,6 +14,7 @@ def get_plugins(desktop: Desktop) -> [Plugin]: system.System(desktop), colors.Colors(desktop), gtk.Gtk(desktop), + icons.Icons(desktop), kvantum.Kvantum(), wallpaper.Wallpaper(desktop), firefox.Firefox(), diff --git a/src/plugins/gtk.py b/src/plugins/gtk.py index e929bf16..9631423d 100755 --- a/src/plugins/gtk.py +++ b/src/plugins/gtk.py @@ -89,7 +89,7 @@ def __init__(self): class _Mate(PluginCommandline): def __init__(self): - super().__init__(['dconf write', '/org/mate/desktop/interface/gtk-theme', '"\'{theme}\'"']) + super().__init__(['dconf', 'write', '/org/mate/desktop/interface/gtk-theme', '\'{theme}\'']) self.theme_light = 'Yaru' self.theme_dark = 'Yaru-dark' diff --git a/src/plugins/icons.py b/src/plugins/icons.py index 367e8f98..4508038e 100644 --- a/src/plugins/icons.py +++ b/src/plugins/icons.py @@ -1,4 +1,4 @@ -from meta import Desktop +from src.meta import Desktop from src.plugins._plugin import PluginDesktopDependent, PluginCommandline @@ -13,7 +13,7 @@ def __init__(self, desktop: Desktop): class _Mate(PluginCommandline): def __init__(self): - super().__init__(['dconf', 'write', '/org/mate/desktop/interface/icon-theme', '"\'{theme}\'"']) + super().__init__(['dconf', 'write', '/org/mate/desktop/interface/icon-theme', '\'{theme}\'']) self.theme_light = 'Yaru' self.theme_dark = 'Yaru-dark' diff --git a/src/plugins/system.py b/src/plugins/system.py index 85069d7a..5c6904a4 100644 --- a/src/plugins/system.py +++ b/src/plugins/system.py @@ -129,7 +129,7 @@ class _Mate(PluginCommandline): theme_directories = ['/usr/share/themes', f'{Path.home()}/.themes'] def __init__(self): - super().__init__(['dconf', 'write', '/org/mate/marco/general/theme', '"\'{theme}\'"']) + super().__init__(['dconf', 'write', '/org/mate/marco/general/theme', '\'{theme}\'']) self.theme_light = 'Yaru' self.theme_dark = 'Yaru-dark' @@ -143,7 +143,7 @@ def available_themes(self) -> dict: with os.scandir(directory) as entries: for d in entries: - index = d.name + '/index.theme' + index = d.path + '/index.theme' if not os.path.isfile(index): continue @@ -155,7 +155,8 @@ def available_themes(self) -> dict: except KeyError: continue - return {} + return {t: t for t in themes} + @property def available(self): return self.check_command(['dconf', 'help']) From a8e9bf2a546852a04ce8165856324e94e8674377 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 12:20:31 +0200 Subject: [PATCH 05/35] Better use of python paths --- src/plugins/system.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/plugins/system.py b/src/plugins/system.py index 5c6904a4..a3964824 100644 --- a/src/plugins/system.py +++ b/src/plugins/system.py @@ -126,7 +126,7 @@ def available_themes(self) -> dict: class _Mate(PluginCommandline): - theme_directories = ['/usr/share/themes', f'{Path.home()}/.themes'] + theme_directories = [Path('/usr/share/themes'), Path.home() / '.themes'] def __init__(self): super().__init__(['dconf', 'write', '/org/mate/marco/general/theme', '\'{theme}\'']) @@ -138,22 +138,21 @@ def available_themes(self) -> dict: themes = [] for directory in self.theme_directories: - if not os.path.isdir(directory): + if not directory.is_dir(): continue - with os.scandir(directory) as entries: - for d in entries: - index = d.path + '/index.theme' - if not os.path.isfile(index): - continue + for d in directory.iterdir(): + index = d / 'index.theme' + if not index.is_file(): + continue - config = ConfigParser() - config.read(index) - try: - theme = config['X-GNOME-Metatheme']['MetacityTheme'] - themes.append(theme) - except KeyError: - continue + config = ConfigParser() + config.read(index) + try: + theme = config['X-GNOME-Metatheme']['MetacityTheme'] + themes.append(theme) + except KeyError: + continue return {t: t for t in themes} From 3c965b47ca6748417cd362184c1a3337a5902ff0 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 12:20:54 +0200 Subject: [PATCH 06/35] Update config version due to new plugins being added --- src/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.py b/src/config.py index ad13e713..e15fafb1 100755 --- a/src/config.py +++ b/src/config.py @@ -341,7 +341,7 @@ def defaults(self) -> dict: # NOTE: if you change or add new values here, make sure to update the version number and update_config() method conf_default = { - 'version': 3.2, + 'version': 3.3, 'running': False, 'dark_mode': False, 'mode': Modes.MANUAL.value, From 761f656330dfe57da12d80567616fa6a80ee3ee2 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 12:35:01 +0200 Subject: [PATCH 07/35] Improve pid iteration --- src/plugins/konsole.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index a771248c..b2dd06e0 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -65,8 +65,8 @@ def set_mode(self, dark: bool) -> bool: # Get the process IDs of all running Konsole instances owned by the current user process_ids = [ - proc.pid for proc in psutil.process_iter(['name', 'username']) - if proc.info['name'] == 'konsole' and proc.info['username'] == os.getlogin() + proc.pid for proc in psutil.process_iter() + if proc.name() == 'konsole' and proc.username() == os.getlogin() ] # loop: console processes @@ -77,8 +77,8 @@ def set_mode(self, dark: bool) -> bool: set_profile('org.kde.yakuake', profile) process_ids = [ - proc.pid for proc in psutil.process_iter(['name', 'username']) - if proc.info['name'] == 'dolphin' and proc.info['username'] == os.getlogin() + proc.pid for proc in psutil.process_iter() + if proc.name() == 'dolphin' and proc.username() == os.getlogin() ] # loop: dolphin processes From 17d0b3f517e0ca318cc45c48d1db0d33c6112b8c Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 14:59:47 +0200 Subject: [PATCH 08/35] Add a okular plugin --- src/plugins/__init__.py | 3 +- src/plugins/okular.py | 127 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/plugins/okular.py diff --git a/src/plugins/__init__.py b/src/plugins/__init__.py index 4fae012f..58a36684 100755 --- a/src/plugins/__init__.py +++ b/src/plugins/__init__.py @@ -1,6 +1,6 @@ from src.meta import Desktop from src.plugins import system, colors, gtk, icons, kvantum, wallpaper, custom -from src.plugins import firefox, brave, gedit, only_office +from src.plugins import firefox, brave, gedit, only_office, okular from src.plugins import vscode, atom, konsole from src.plugins import sound, notify @@ -23,6 +23,7 @@ def get_plugins(desktop: Desktop) -> [Plugin]: atom.Atom(), gedit.Gedit(), only_office.OnlyOffice(), + okular.Okular(), konsole.Konsole(), custom.Custom(), sound.Sound(), diff --git a/src/plugins/okular.py b/src/plugins/okular.py new file mode 100644 index 00000000..79832ef7 --- /dev/null +++ b/src/plugins/okular.py @@ -0,0 +1,127 @@ +import os +from configparser import ConfigParser +from pathlib import Path + +import psutil +from PySide6.QtDBus import QDBusConnection, QDBusMessage + +from ._plugin import Plugin + + +class Okular(Plugin): + """Inspired by: https://gitlab.com/LADlSLAV/yabotss/-/blob/main/darkman_examples_kde_plasma/dark-mode.d/10_set_theme_okular_dark.sh""" + + def __init__(self): + super().__init__() + self._theme_light = '' + self._theme_dark = '' + + @property + def user_paths(self) -> [Path]: + path = Path.home() / '.config/okularpartrc' + if path.is_file(): + yield path + + path = Path.home() / '.var/app/org.kde.okular/config/okularpartrc' + if path.is_file(): + yield path + + return + + @property + def available(self) -> bool: + try: + next(self.user_paths) + return True + except StopIteration: + return False + + def set_mode(self, dark: bool): + if not self.enabled: + return False + + process_ids = [ + proc.pid for proc in psutil.process_iter(['name', 'username']) + if proc.name() == 'okular' and proc.username() == os.getlogin() + ] + # this is if okular is running in a flatpak + process_ids.append(2) + + connection = QDBusConnection.sessionBus() + for pid in process_ids: + message = QDBusMessage.createMethodCall( + f'org.kde.okular-{pid}', + '/okular', + 'org.kde.okular', + 'slotSetChangeColors' + ) + message.setArguments([dark]) + connection.call(message) + + # now change the config for future starts of the app + for path in self.user_paths: + config = ConfigParser() + config.optionxform = str + config.read(path) + + if dark: + if not config.has_section('Document'): + config.add_section('Document') + config['Document']['ChangeColors'] = 'true' + else: + config.remove_option('Document', 'ChangeColors') + if len(config.options('Document')) == 0: + config.remove_section('Document') + + with open(path, 'w') as file: + config.write(file, space_around_delimiters=False) + + def set_theme(self, theme: str): + pass + + @property + def available_themes(self) -> dict: + # these are color changing modes in Okulars accessibility settings + return { + '': 'Invert colors', + 'InvertLightness': 'Invert lightness', + 'InvertLuma': 'Invert luma (sRGB linear)', + 'InvertLumaSymmetric': 'Invert luma (symmetrical)' + } + + def get_input(self, widget): + inputs = super().get_input(widget) + n_items = len(self.available_themes) + + # modify light item to make it clear that this shows the original without modifications + for i in range(n_items): + inputs[0].removeItem(0) + inputs[0].addItem('Don\'t modify anything') + + return inputs + + @property + def theme_dark(self): + return self._theme_dark + + @theme_dark.setter + def theme_dark(self, value): + self._theme_dark = value + + for path in self.user_paths: + config = ConfigParser() + config.optionxform = str + config.read(path) + + if value == '': + if config.has_section('Document'): + config.remove_option('Document', 'RenderMode') + if len(config.options('Document')) == 0: + config.remove_section('Document') + else: + if not config.has_section('Document'): + config.add_section('Document') + config['Document']['RenderMode'] = value + + with open(path, 'w') as file: + config.write(file, space_around_delimiters=False) From e2e651f5027b0855939a40223f238efe0a5de462 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 15:47:11 +0200 Subject: [PATCH 09/35] Restructure the project --- .gitignore | 2 +- main.py | 107 ------------------ resources/yin-yang | 2 +- tests/test_communication.py | 6 +- tests/test_config.py | 4 +- tests/test_daemon.py | 2 +- tests/test_daemon_handler.py | 6 +- tests/test_plugin_class.py | 2 +- tests/test_plugins.py | 6 +- {src => yin_yang}/__init__.py | 0 yin_yang/__main__.py | 103 +++++++++++++++++ communicate.py => yin_yang/communicate.py | 4 +- {src => yin_yang}/config.py | 4 +- {src => yin_yang}/daemon_handler.py | 4 +- {src => yin_yang}/meta.py | 0 {src => yin_yang}/plugins/__init__.py | 14 +-- {src => yin_yang}/plugins/_plugin.py | 2 +- {src => yin_yang}/plugins/atom.py | 0 {src => yin_yang}/plugins/brave.py | 2 +- {src => yin_yang}/plugins/colors.py | 4 +- {src => yin_yang}/plugins/custom.py | 2 +- {src => yin_yang}/plugins/firefox.py | 0 {src => yin_yang}/plugins/gedit.py | 4 +- {src => yin_yang}/plugins/gtk.py | 6 +- {src => yin_yang}/plugins/icons.py | 4 +- {src => yin_yang}/plugins/konsole.py | 2 +- {src => yin_yang}/plugins/kvantum.py | 2 +- {src => yin_yang}/plugins/notify.py | 2 +- {src => yin_yang}/plugins/okular.py | 0 {src => yin_yang}/plugins/only_office.py | 2 +- {src => yin_yang}/plugins/sound.py | 2 +- {src => yin_yang}/plugins/system.py | 4 +- {src => yin_yang}/plugins/vscode.py | 0 {src => yin_yang}/plugins/wallpaper.py | 2 +- resources_rc.py => yin_yang/resources_rc.py | 0 src/yin_yang.py => yin_yang/theme_switcher.py | 10 +- {src => yin_yang}/ui/__init__.py | 0 {src => yin_yang}/ui/main_window.py | 0 {src => yin_yang}/ui/main_window_connector.py | 10 +- 39 files changed, 161 insertions(+), 165 deletions(-) delete mode 100755 main.py rename {src => yin_yang}/__init__.py (100%) create mode 100755 yin_yang/__main__.py rename communicate.py => yin_yang/communicate.py (98%) rename {src => yin_yang}/config.py (99%) rename {src => yin_yang}/daemon_handler.py (97%) rename {src => yin_yang}/meta.py (100%) rename {src => yin_yang}/plugins/__init__.py (60%) rename {src => yin_yang}/plugins/_plugin.py (99%) rename {src => yin_yang}/plugins/atom.py (100%) rename {src => yin_yang}/plugins/brave.py (95%) rename {src => yin_yang}/plugins/colors.py (89%) rename {src => yin_yang}/plugins/custom.py (94%) rename {src => yin_yang}/plugins/firefox.py (100%) rename {src => yin_yang}/plugins/gedit.py (89%) rename {src => yin_yang}/plugins/gtk.py (93%) rename {src => yin_yang}/plugins/icons.py (83%) rename {src => yin_yang}/plugins/konsole.py (99%) rename {src => yin_yang}/plugins/kvantum.py (95%) rename {src => yin_yang}/plugins/notify.py (84%) rename {src => yin_yang}/plugins/okular.py (100%) rename {src => yin_yang}/plugins/only_office.py (95%) rename {src => yin_yang}/plugins/sound.py (89%) rename {src => yin_yang}/plugins/system.py (97%) rename {src => yin_yang}/plugins/vscode.py (100%) rename {src => yin_yang}/plugins/wallpaper.py (98%) rename resources_rc.py => yin_yang/resources_rc.py (100%) rename src/yin_yang.py => yin_yang/theme_switcher.py (88%) rename {src => yin_yang}/ui/__init__.py (100%) rename {src => yin_yang}/ui/main_window.py (100%) rename {src => yin_yang}/ui/main_window_connector.py (98%) diff --git a/.gitignore b/.gitignore index aa9a011a..a3ea2b16 100755 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ __pycache__ build-test* build-ui-* .vscode -src/build.py +yin_yang/build.py setup.py .idea/ diff --git a/main.py b/main.py deleted file mode 100755 index a1a14084..00000000 --- a/main.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/env python3 - -import sys -import logging -from argparse import ArgumentParser -from logging.handlers import RotatingFileHandler -from pathlib import Path - -from PySide6 import QtWidgets -from PySide6.QtCore import QTranslator, QLibraryInfo, QLocale -from systemd import journal - -from src import daemon_handler -from src.meta import ConfigEvent -from src import yin_yang -from src.config import config, Modes -from src.ui import main_window_connector - -logger = logging.getLogger() - - -def setup_logger(use_systemd_journal: bool): - if use_systemd_journal: - logger.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER='yin_yang')) - - # __debug__ is true when you run main.py without the -O argument (python main.py) - # noinspection PyUnreachableCode - if __debug__: - # noinspection SpellCheckingInspection - logging.basicConfig( - level=logging.DEBUG, - format='%(asctime)s %(levelname)s - %(name)s: %(message)s' - ) - else: - # if you run it with "python -O main.py" instead, debug is false - - # let the default logger print to the console - # noinspection SpellCheckingInspection - logging.basicConfig( - level=logging.WARNING, - format='%(asctime)s %(levelname)s - %(name)s: %(message)s' - ) - # and add a handler that limits the size to 1 GB - file_handler = RotatingFileHandler( - str(Path.home()) + '/.local/share/yin_yang.log', - maxBytes=10**9, backupCount=1 - ) - logging.root.addHandler(file_handler) - - -def main(arguments): - # checks whether $ yin-yang is run without args - if len(sys.argv) == 1: - config.add_event_listener(ConfigEvent.SAVE, daemon_handler.watcher) - config.add_event_listener(ConfigEvent.CHANGE, daemon_handler.watcher) - # load GUI - app = QtWidgets.QApplication(sys.argv) - - # load translation - try: - lang = QLocale().name() - logger.debug(f'Using language {lang}') - - # system translations - path = QLibraryInfo.path(QLibraryInfo.TranslationsPath) - translator = QTranslator(app) - if translator.load(QLocale.system(), 'qtbase', '_', path): - app.installTranslator(translator) - else: - raise FileNotFoundError('Error while loading system translations!') - - # application translations - translator = QTranslator(app) - path = ':translations' - if translator.load(QLocale.system(), 'yin_yang', '.', path): - app.installTranslator(translator) - else: - raise FileNotFoundError('Error while loading application translations!') - - except Exception as e: - logger.error(str(e)) - print('Error while loading translation. Using default language.') - - window = main_window_connector.MainWindow() - window.show() - sys.exit(app.exec()) - - if arguments.toggle: - # terminate any running instances - config.running = False - config.mode = Modes.MANUAL - yin_yang.set_mode(not config.dark_mode) - - if arguments.systemd: - yin_yang.set_desired_theme() - - -if __name__ == "__main__": - # using ArgumentParser for parsing arguments - parser = ArgumentParser() - parser.add_argument("-t", "--toggle", - help="toggles Yin-Yang", - action="store_true") - parser.add_argument("--systemd", help="uses systemd journal handler and applies desired theme", action='store_true') - args = parser.parse_args() - setup_logger(args.systemd) - main(args) diff --git a/resources/yin-yang b/resources/yin-yang index 24d9d2f3..adceaa15 100755 --- a/resources/yin-yang +++ b/resources/yin-yang @@ -1,3 +1,3 @@ #!/bin/bash cd /opt/yin-yang/ || exit -python3 -O /opt/yin-yang/main.py "$@" +python3 -Om /opt/yin-yang/yin_yang "$@" diff --git a/tests/test_communication.py b/tests/test_communication.py index 0fc33c6f..32e52259 100644 --- a/tests/test_communication.py +++ b/tests/test_communication.py @@ -6,9 +6,9 @@ from subprocess import Popen, PIPE import communicate -from src.meta import PluginKey -from src.config import config -from src.yin_yang import should_be_dark +from yin_yang.meta import PluginKey +from yin_yang.config import config +from yin_yang.theme_switcher import should_be_dark def should_be_dark_extensions(time_current: int, time_dark: int): diff --git a/tests/test_config.py b/tests/test_config.py index 6ac98c5c..79b13087 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -3,8 +3,8 @@ from pathlib import Path from typing import Optional -from src.config import config, ConfigWatcher, update_config -from src.meta import Desktop, Modes, PluginKey, ConfigEvent +from yin_yang.config import config, ConfigWatcher, update_config +from yin_yang.meta import Desktop, Modes, PluginKey, ConfigEvent config_path = f"{Path.home()}/.config/yin_yang/yin_yang_dev.json" diff --git a/tests/test_daemon.py b/tests/test_daemon.py index d57a77a7..4f34729f 100644 --- a/tests/test_daemon.py +++ b/tests/test_daemon.py @@ -1,7 +1,7 @@ import unittest from datetime import time -from src.yin_yang import should_be_dark +from yin_yang.theme_switcher import should_be_dark class DaemonTest(unittest.TestCase): diff --git a/tests/test_daemon_handler.py b/tests/test_daemon_handler.py index 8173340d..0d845b43 100644 --- a/tests/test_daemon_handler.py +++ b/tests/test_daemon_handler.py @@ -5,9 +5,9 @@ from datetime import time from os.path import isfile -from src import daemon_handler -from src.config import config -from src.meta import Modes, ConfigEvent +from yin_yang import daemon_handler +from yin_yang.config import config +from yin_yang.meta import Modes, ConfigEvent class DaemonTest(unittest.TestCase): diff --git a/tests/test_plugin_class.py b/tests/test_plugin_class.py index d91a6484..61a43f54 100644 --- a/tests/test_plugin_class.py +++ b/tests/test_plugin_class.py @@ -2,7 +2,7 @@ from PySide6.QtGui import QColor -from src.plugins._plugin import PluginCommandline, Plugin, get_qcolor_from_int, get_int_from_qcolor +from yin_yang.plugins._plugin import PluginCommandline, Plugin, get_qcolor_from_int, get_int_from_qcolor class MinimalPlugin(Plugin): diff --git a/tests/test_plugins.py b/tests/test_plugins.py index d10a6c28..f6fe3a5e 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -1,8 +1,8 @@ import unittest -from src.config import config -from src.config import plugins -from src.plugins._plugin import Plugin, ExternalPlugin +from yin_yang.config import config +from yin_yang.config import plugins +from yin_yang.plugins._plugin import Plugin, ExternalPlugin class PluginsTest(unittest.TestCase): diff --git a/src/__init__.py b/yin_yang/__init__.py similarity index 100% rename from src/__init__.py rename to yin_yang/__init__.py diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py new file mode 100755 index 00000000..dfc3569d --- /dev/null +++ b/yin_yang/__main__.py @@ -0,0 +1,103 @@ +#!/bin/env python3 + +import sys +import logging +from argparse import ArgumentParser +from logging.handlers import RotatingFileHandler +from pathlib import Path + +from PySide6 import QtWidgets +from PySide6.QtCore import QTranslator, QLibraryInfo, QLocale +from systemd import journal + +from yin_yang import daemon_handler +from yin_yang.meta import ConfigEvent +from yin_yang import theme_switcher +from yin_yang.config import config, Modes +from yin_yang.ui import main_window_connector + +logger = logging.getLogger() + + +def setup_logger(use_systemd_journal: bool): + if use_systemd_journal: + logger.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER='yin_yang')) + + # __debug__ is true when you run __main__.py without the -O argument (python __main__.py) + # noinspection PyUnreachableCode + if __debug__: + # noinspection SpellCheckingInspection + logging.basicConfig( + level=logging.DEBUG, + format='%(asctime)s %(levelname)s - %(name)s: %(message)s' + ) + else: + # if you run it with "python -O __main__.py" instead, debug is false + + # let the default logger print to the console + # noinspection SpellCheckingInspection + logging.basicConfig( + level=logging.WARNING, + format='%(asctime)s %(levelname)s - %(name)s: %(message)s' + ) + # and add a handler that limits the size to 1 GB + file_handler = RotatingFileHandler( + str(Path.home()) + '/.local/share/yin_yang.log', + maxBytes=10**9, backupCount=1 + ) + logging.root.addHandler(file_handler) + + +# using ArgumentParser for parsing arguments +parser = ArgumentParser() +parser.add_argument("-t", "--toggle", + help="toggles Yin-Yang", + action="store_true") +parser.add_argument("--systemd", help="uses systemd journal handler and applies desired theme", action='store_true') +arguments = parser.parse_args() +setup_logger(arguments.systemd) + +# checks whether $ yin-yang is run without args +if len(sys.argv) == 1: + config.add_event_listener(ConfigEvent.SAVE, daemon_handler.watcher) + config.add_event_listener(ConfigEvent.CHANGE, daemon_handler.watcher) + # load GUI + app = QtWidgets.QApplication(sys.argv) + + # load translation + try: + lang = QLocale().name() + logger.debug(f'Using language {lang}') + + # system translations + path = QLibraryInfo.path(QLibraryInfo.TranslationsPath) + translator = QTranslator(app) + if translator.load(QLocale.system(), 'qtbase', '_', path): + app.installTranslator(translator) + else: + raise FileNotFoundError('Error while loading system translations!') + + # application translations + translator = QTranslator(app) + path = ':translations' + if translator.load(QLocale.system(), 'yin_yang', '.', path): + app.installTranslator(translator) + else: + raise FileNotFoundError('Error while loading application translations!') + + except Exception as e: + logger.error(str(e)) + print('Error while loading translation. Using default language.') + + window = main_window_connector.MainWindow() + window.show() + sys.exit(app.exec()) + +if arguments.toggle: + # terminate any running instances + config.running = False + config.mode = Modes.MANUAL + theme_switcher.set_mode(not config.dark_mode) + +if arguments.systemd: + theme_switcher.set_desired_theme() diff --git a/communicate.py b/yin_yang/communicate.py similarity index 98% rename from communicate.py rename to yin_yang/communicate.py index c7bb04dd..b1dca3a7 100755 --- a/communicate.py +++ b/yin_yang/communicate.py @@ -12,8 +12,8 @@ from datetime import datetime, time as dt_time from pathlib import Path -from src.meta import PluginKey -from src.config import config +from yin_yang.meta import PluginKey +from yin_yang.config import config logging.basicConfig(filename=str(Path.home()) + '/.local/share/yin_yang.log', level=logging.DEBUG, format='%(asctime)s %(levelname)s - %(name)s: %(message)s') diff --git a/src/config.py b/yin_yang/config.py similarity index 99% rename from src/config.py rename to yin_yang/config.py index e15fafb1..fdaa094f 100755 --- a/src/config.py +++ b/yin_yang/config.py @@ -13,8 +13,8 @@ from psutil import process_iter, NoSuchProcess from suntime import Sun, SunTimeException -from src.meta import Modes, Desktop, PluginKey, ConfigEvent -from src.plugins import get_plugins +from yin_yang.meta import Modes, Desktop, PluginKey, ConfigEvent +from yin_yang.plugins import get_plugins logger = logging.getLogger(__name__) diff --git a/src/daemon_handler.py b/yin_yang/daemon_handler.py similarity index 97% rename from src/daemon_handler.py rename to yin_yang/daemon_handler.py index 765016ab..94da1d2e 100644 --- a/src/daemon_handler.py +++ b/yin_yang/daemon_handler.py @@ -4,8 +4,8 @@ from enum import Enum, auto from pathlib import Path -from src.config import ConfigWatcher, config -from src.meta import ConfigEvent, Modes +from yin_yang.config import ConfigWatcher, config +from yin_yang.meta import ConfigEvent, Modes logger = logging.getLogger(__name__) SYSTEMD_PATH = Path.home() / '.local/share/systemd/user' diff --git a/src/meta.py b/yin_yang/meta.py similarity index 100% rename from src/meta.py rename to yin_yang/meta.py diff --git a/src/plugins/__init__.py b/yin_yang/plugins/__init__.py similarity index 60% rename from src/plugins/__init__.py rename to yin_yang/plugins/__init__.py index 58a36684..cd601304 100755 --- a/src/plugins/__init__.py +++ b/yin_yang/plugins/__init__.py @@ -1,12 +1,12 @@ -from src.meta import Desktop -from src.plugins import system, colors, gtk, icons, kvantum, wallpaper, custom -from src.plugins import firefox, brave, gedit, only_office, okular -from src.plugins import vscode, atom, konsole -from src.plugins import sound, notify +from yin_yang.meta import Desktop +from yin_yang.plugins import system, colors, gtk, icons, kvantum, wallpaper, custom +from yin_yang.plugins import firefox, brave, gedit, only_office, okular +from yin_yang.plugins import vscode, atom, konsole +from yin_yang.plugins import sound, notify # NOTE initialize your plugin over here: # The order in the list specifies the order in the config gui -from src.plugins._plugin import Plugin, ExternalPlugin +from yin_yang.plugins._plugin import Plugin, ExternalPlugin def get_plugins(desktop: Desktop) -> [Plugin]: @@ -31,5 +31,5 @@ def get_plugins(desktop: Desktop) -> [Plugin]: ] -# this lets us skip all external plugins in yin_yang.py while keeping _plugin "private" +# this lets us skip all external plugins in theme_switcher.py while keeping _plugin "private" ExternalPlugin = ExternalPlugin diff --git a/src/plugins/_plugin.py b/yin_yang/plugins/_plugin.py similarity index 99% rename from src/plugins/_plugin.py rename to yin_yang/plugins/_plugin.py index 4d8d535f..0268918a 100644 --- a/src/plugins/_plugin.py +++ b/yin_yang/plugins/_plugin.py @@ -6,7 +6,7 @@ from PySide6.QtGui import QColor, QRgba64 from PySide6.QtWidgets import QGroupBox, QHBoxLayout, QLineEdit, QComboBox -from src.meta import UnsupportedDesktopError +from yin_yang.meta import UnsupportedDesktopError logger = logging.getLogger(__name__) diff --git a/src/plugins/atom.py b/yin_yang/plugins/atom.py similarity index 100% rename from src/plugins/atom.py rename to yin_yang/plugins/atom.py diff --git a/src/plugins/brave.py b/yin_yang/plugins/brave.py similarity index 95% rename from src/plugins/brave.py rename to yin_yang/plugins/brave.py index ac845668..a50223d0 100644 --- a/src/plugins/brave.py +++ b/yin_yang/plugins/brave.py @@ -5,7 +5,7 @@ from PySide6.QtGui import QColor from PySide6.QtWidgets import QWidget, QVBoxLayout, QLineEdit, QPushButton -from src.plugins._plugin import Plugin, get_int_from_qcolor +from yin_yang.plugins._plugin import Plugin, get_int_from_qcolor path = f'{Path.home()}/.config/BraveSoftware/Brave-Browser/Default/Preferences' diff --git a/src/plugins/colors.py b/yin_yang/plugins/colors.py similarity index 89% rename from src/plugins/colors.py rename to yin_yang/plugins/colors.py index d58abd1a..d0536d44 100644 --- a/src/plugins/colors.py +++ b/yin_yang/plugins/colors.py @@ -1,8 +1,8 @@ import subprocess import re -from src.meta import Desktop -from src.plugins._plugin import Plugin, PluginDesktopDependent, PluginCommandline +from yin_yang.meta import Desktop +from yin_yang.plugins._plugin import Plugin, PluginDesktopDependent, PluginCommandline class Colors(PluginDesktopDependent): diff --git a/src/plugins/custom.py b/yin_yang/plugins/custom.py similarity index 94% rename from src/plugins/custom.py rename to yin_yang/plugins/custom.py index 4e477816..ea0bce1d 100644 --- a/src/plugins/custom.py +++ b/yin_yang/plugins/custom.py @@ -2,7 +2,7 @@ from PySide6.QtWidgets import QLineEdit -from src.plugins._plugin import PluginCommandline +from yin_yang.plugins._plugin import PluginCommandline class Custom(PluginCommandline): diff --git a/src/plugins/firefox.py b/yin_yang/plugins/firefox.py similarity index 100% rename from src/plugins/firefox.py rename to yin_yang/plugins/firefox.py diff --git a/src/plugins/gedit.py b/yin_yang/plugins/gedit.py similarity index 89% rename from src/plugins/gedit.py rename to yin_yang/plugins/gedit.py index ceba099b..9c6d3843 100644 --- a/src/plugins/gedit.py +++ b/yin_yang/plugins/gedit.py @@ -2,8 +2,8 @@ from os.path import isdir from xml.etree import ElementTree -from src.plugins._plugin import PluginCommandline -from src.plugins.system import test_gnome_availability +from yin_yang.plugins._plugin import PluginCommandline +from yin_yang.plugins.system import test_gnome_availability path = '/usr/share/gtksourceview-4/styles/' diff --git a/src/plugins/gtk.py b/yin_yang/plugins/gtk.py similarity index 93% rename from src/plugins/gtk.py rename to yin_yang/plugins/gtk.py index 9631423d..6ccf1170 100755 --- a/src/plugins/gtk.py +++ b/yin_yang/plugins/gtk.py @@ -4,9 +4,9 @@ from PySide6.QtDBus import QDBusConnection, QDBusMessage -from src.meta import Desktop -from src.plugins._plugin import PluginDesktopDependent, Plugin, PluginCommandline -from src.plugins.system import test_gnome_availability +from yin_yang.meta import Desktop +from yin_yang.plugins._plugin import PluginDesktopDependent, Plugin, PluginCommandline +from yin_yang.plugins.system import test_gnome_availability logger = logging.getLogger(__name__) diff --git a/src/plugins/icons.py b/yin_yang/plugins/icons.py similarity index 83% rename from src/plugins/icons.py rename to yin_yang/plugins/icons.py index 4508038e..cf0a23c5 100644 --- a/src/plugins/icons.py +++ b/yin_yang/plugins/icons.py @@ -1,5 +1,5 @@ -from src.meta import Desktop -from src.plugins._plugin import PluginDesktopDependent, PluginCommandline +from yin_yang.meta import Desktop +from yin_yang.plugins._plugin import PluginDesktopDependent, PluginCommandline class Icons(PluginDesktopDependent): diff --git a/src/plugins/konsole.py b/yin_yang/plugins/konsole.py similarity index 99% rename from src/plugins/konsole.py rename to yin_yang/plugins/konsole.py index b2dd06e0..05976ee6 100644 --- a/src/plugins/konsole.py +++ b/yin_yang/plugins/konsole.py @@ -10,7 +10,7 @@ import psutil from PySide6.QtDBus import QDBusConnection, QDBusMessage -from src.plugins._plugin import Plugin +from yin_yang.plugins._plugin import Plugin logger = logging.getLogger(__name__) diff --git a/src/plugins/kvantum.py b/yin_yang/plugins/kvantum.py similarity index 95% rename from src/plugins/kvantum.py rename to yin_yang/plugins/kvantum.py index b02da05e..59a0e534 100755 --- a/src/plugins/kvantum.py +++ b/yin_yang/plugins/kvantum.py @@ -1,7 +1,7 @@ import os from pathlib import Path -from src.plugins._plugin import PluginCommandline +from yin_yang.plugins._plugin import PluginCommandline class Kvantum(PluginCommandline): diff --git a/src/plugins/notify.py b/yin_yang/plugins/notify.py similarity index 84% rename from src/plugins/notify.py rename to yin_yang/plugins/notify.py index 423c947b..8941f2f7 100644 --- a/src/plugins/notify.py +++ b/yin_yang/plugins/notify.py @@ -1,4 +1,4 @@ -from src.plugins._plugin import PluginCommandline +from yin_yang.plugins._plugin import PluginCommandline class Notification(PluginCommandline): diff --git a/src/plugins/okular.py b/yin_yang/plugins/okular.py similarity index 100% rename from src/plugins/okular.py rename to yin_yang/plugins/okular.py diff --git a/src/plugins/only_office.py b/yin_yang/plugins/only_office.py similarity index 95% rename from src/plugins/only_office.py rename to yin_yang/plugins/only_office.py index 18725854..84df79e7 100644 --- a/src/plugins/only_office.py +++ b/yin_yang/plugins/only_office.py @@ -2,7 +2,7 @@ from os.path import isfile from pathlib import Path -from src.plugins._plugin import Plugin +from yin_yang.plugins._plugin import Plugin config_path = f'{Path.home()}/.config/onlyoffice/DesktopEditors.conf' diff --git a/src/plugins/sound.py b/yin_yang/plugins/sound.py similarity index 89% rename from src/plugins/sound.py rename to yin_yang/plugins/sound.py index 2b6e32cc..1efa492a 100644 --- a/src/plugins/sound.py +++ b/yin_yang/plugins/sound.py @@ -1,6 +1,6 @@ import subprocess -from src.plugins._plugin import PluginCommandline +from yin_yang.plugins._plugin import PluginCommandline class Sound(PluginCommandline): diff --git a/src/plugins/system.py b/yin_yang/plugins/system.py similarity index 97% rename from src/plugins/system.py rename to yin_yang/plugins/system.py index a3964824..b6023aef 100644 --- a/src/plugins/system.py +++ b/yin_yang/plugins/system.py @@ -8,8 +8,8 @@ from PySide6.QtCore import QLocale -from src.meta import Desktop -from src.plugins._plugin import PluginDesktopDependent, PluginCommandline +from yin_yang.meta import Desktop +from yin_yang.plugins._plugin import PluginDesktopDependent, PluginCommandline logger = logging.getLogger(__name__) diff --git a/src/plugins/vscode.py b/yin_yang/plugins/vscode.py similarity index 100% rename from src/plugins/vscode.py rename to yin_yang/plugins/vscode.py diff --git a/src/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py similarity index 98% rename from src/plugins/wallpaper.py rename to yin_yang/plugins/wallpaper.py index abc4086f..65901853 100755 --- a/src/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -4,7 +4,7 @@ from PySide6.QtWidgets import QDialogButtonBox, QVBoxLayout, QWidget, QLineEdit from PySide6.QtDBus import QDBusConnection, QDBusMessage -from src.meta import Desktop +from yin_yang.meta import Desktop from ._plugin import PluginDesktopDependent, PluginCommandline, Plugin from .system import test_gnome_availability diff --git a/resources_rc.py b/yin_yang/resources_rc.py similarity index 100% rename from resources_rc.py rename to yin_yang/resources_rc.py diff --git a/src/yin_yang.py b/yin_yang/theme_switcher.py similarity index 88% rename from src/yin_yang.py rename to yin_yang/theme_switcher.py index ebb2c971..69b274d9 100755 --- a/src/yin_yang.py +++ b/yin_yang/theme_switcher.py @@ -12,11 +12,11 @@ import time from threading import Thread -from src.plugins.notify import Notification -from src.plugins.sound import Sound -from src.daemon_handler import update_times -from src.meta import PluginKey -from src.config import config, plugins +from yin_yang.plugins.notify import Notification +from yin_yang.plugins.sound import Sound +from yin_yang.daemon_handler import update_times +from yin_yang.meta import PluginKey +from yin_yang.config import config, plugins logger = logging.getLogger(__name__) diff --git a/src/ui/__init__.py b/yin_yang/ui/__init__.py similarity index 100% rename from src/ui/__init__.py rename to yin_yang/ui/__init__.py diff --git a/src/ui/main_window.py b/yin_yang/ui/main_window.py similarity index 100% rename from src/ui/main_window.py rename to yin_yang/ui/main_window.py diff --git a/src/ui/main_window_connector.py b/yin_yang/ui/main_window_connector.py similarity index 98% rename from src/ui/main_window_connector.py rename to yin_yang/ui/main_window_connector.py index fc571b41..1ae8c5b8 100755 --- a/src/ui/main_window_connector.py +++ b/yin_yang/ui/main_window_connector.py @@ -6,12 +6,12 @@ from PySide6.QtGui import QScreen, QColor from PySide6.QtWidgets import QFileDialog, QMessageBox, QDialogButtonBox, QColorDialog,QGroupBox -from src.ui.main_window import Ui_main_window +from yin_yang.ui.main_window import Ui_main_window -from src.yin_yang import set_desired_theme -from src.meta import ConfigEvent -from src.meta import PluginKey -from src.config import config, Modes, plugins, ConfigWatcher +from yin_yang.theme_switcher import set_desired_theme +from yin_yang.meta import ConfigEvent +from yin_yang.meta import PluginKey +from yin_yang.config import config, Modes, plugins, ConfigWatcher logger = logging.getLogger(__name__) From 6c839919d312b47be34d47a8107aa4c7c82b8e5e Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 15:52:12 +0200 Subject: [PATCH 10/35] Use relative imports --- yin_yang/communicate.py | 4 ++-- yin_yang/config.py | 4 ++-- yin_yang/daemon_handler.py | 4 ++-- yin_yang/plugins/__init__.py | 10 +++++----- yin_yang/plugins/_plugin.py | 2 +- yin_yang/plugins/brave.py | 2 +- yin_yang/plugins/colors.py | 4 ++-- yin_yang/plugins/custom.py | 2 +- yin_yang/plugins/gedit.py | 4 ++-- yin_yang/plugins/gtk.py | 6 +++--- yin_yang/plugins/icons.py | 4 ++-- yin_yang/plugins/konsole.py | 2 +- yin_yang/plugins/kvantum.py | 2 +- yin_yang/plugins/notify.py | 2 +- yin_yang/plugins/only_office.py | 2 +- yin_yang/plugins/sound.py | 2 +- yin_yang/plugins/system.py | 4 ++-- yin_yang/plugins/wallpaper.py | 2 +- yin_yang/theme_switcher.py | 10 +++++----- yin_yang/ui/main_window_connector.py | 10 ++++------ 20 files changed, 40 insertions(+), 42 deletions(-) diff --git a/yin_yang/communicate.py b/yin_yang/communicate.py index b1dca3a7..2fbb7222 100755 --- a/yin_yang/communicate.py +++ b/yin_yang/communicate.py @@ -12,8 +12,8 @@ from datetime import datetime, time as dt_time from pathlib import Path -from yin_yang.meta import PluginKey -from yin_yang.config import config +from .meta import PluginKey +from .config import config logging.basicConfig(filename=str(Path.home()) + '/.local/share/yin_yang.log', level=logging.DEBUG, format='%(asctime)s %(levelname)s - %(name)s: %(message)s') diff --git a/yin_yang/config.py b/yin_yang/config.py index fdaa094f..b63c49a3 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -13,8 +13,8 @@ from psutil import process_iter, NoSuchProcess from suntime import Sun, SunTimeException -from yin_yang.meta import Modes, Desktop, PluginKey, ConfigEvent -from yin_yang.plugins import get_plugins +from .meta import Modes, Desktop, PluginKey, ConfigEvent +from .plugins import get_plugins logger = logging.getLogger(__name__) diff --git a/yin_yang/daemon_handler.py b/yin_yang/daemon_handler.py index 94da1d2e..5b7c92f7 100644 --- a/yin_yang/daemon_handler.py +++ b/yin_yang/daemon_handler.py @@ -4,8 +4,8 @@ from enum import Enum, auto from pathlib import Path -from yin_yang.config import ConfigWatcher, config -from yin_yang.meta import ConfigEvent, Modes +from .config import ConfigWatcher, config +from .meta import ConfigEvent, Modes logger = logging.getLogger(__name__) SYSTEMD_PATH = Path.home() / '.local/share/systemd/user' diff --git a/yin_yang/plugins/__init__.py b/yin_yang/plugins/__init__.py index cd601304..c40941c2 100755 --- a/yin_yang/plugins/__init__.py +++ b/yin_yang/plugins/__init__.py @@ -1,8 +1,8 @@ -from yin_yang.meta import Desktop -from yin_yang.plugins import system, colors, gtk, icons, kvantum, wallpaper, custom -from yin_yang.plugins import firefox, brave, gedit, only_office, okular -from yin_yang.plugins import vscode, atom, konsole -from yin_yang.plugins import sound, notify +from ..meta import Desktop +from . import system, colors, gtk, icons, kvantum, wallpaper, custom +from . import firefox, brave, gedit, only_office, okular +from . import vscode, atom, konsole +from . import sound, notify # NOTE initialize your plugin over here: # The order in the list specifies the order in the config gui diff --git a/yin_yang/plugins/_plugin.py b/yin_yang/plugins/_plugin.py index 0268918a..0568d08f 100644 --- a/yin_yang/plugins/_plugin.py +++ b/yin_yang/plugins/_plugin.py @@ -6,7 +6,7 @@ from PySide6.QtGui import QColor, QRgba64 from PySide6.QtWidgets import QGroupBox, QHBoxLayout, QLineEdit, QComboBox -from yin_yang.meta import UnsupportedDesktopError +from ..meta import UnsupportedDesktopError logger = logging.getLogger(__name__) diff --git a/yin_yang/plugins/brave.py b/yin_yang/plugins/brave.py index a50223d0..8b2cf451 100644 --- a/yin_yang/plugins/brave.py +++ b/yin_yang/plugins/brave.py @@ -5,7 +5,7 @@ from PySide6.QtGui import QColor from PySide6.QtWidgets import QWidget, QVBoxLayout, QLineEdit, QPushButton -from yin_yang.plugins._plugin import Plugin, get_int_from_qcolor +from ._plugin import Plugin, get_int_from_qcolor path = f'{Path.home()}/.config/BraveSoftware/Brave-Browser/Default/Preferences' diff --git a/yin_yang/plugins/colors.py b/yin_yang/plugins/colors.py index d0536d44..5796d57d 100644 --- a/yin_yang/plugins/colors.py +++ b/yin_yang/plugins/colors.py @@ -1,8 +1,8 @@ import subprocess import re -from yin_yang.meta import Desktop -from yin_yang.plugins._plugin import Plugin, PluginDesktopDependent, PluginCommandline +from ..meta import Desktop +from ._plugin import Plugin, PluginDesktopDependent, PluginCommandline class Colors(PluginDesktopDependent): diff --git a/yin_yang/plugins/custom.py b/yin_yang/plugins/custom.py index ea0bce1d..2f5547ce 100644 --- a/yin_yang/plugins/custom.py +++ b/yin_yang/plugins/custom.py @@ -2,7 +2,7 @@ from PySide6.QtWidgets import QLineEdit -from yin_yang.plugins._plugin import PluginCommandline +from ._plugin import PluginCommandline class Custom(PluginCommandline): diff --git a/yin_yang/plugins/gedit.py b/yin_yang/plugins/gedit.py index 9c6d3843..3fc45a70 100644 --- a/yin_yang/plugins/gedit.py +++ b/yin_yang/plugins/gedit.py @@ -2,8 +2,8 @@ from os.path import isdir from xml.etree import ElementTree -from yin_yang.plugins._plugin import PluginCommandline -from yin_yang.plugins.system import test_gnome_availability +from ._plugin import PluginCommandline +from .system import test_gnome_availability path = '/usr/share/gtksourceview-4/styles/' diff --git a/yin_yang/plugins/gtk.py b/yin_yang/plugins/gtk.py index 6ccf1170..79b36759 100755 --- a/yin_yang/plugins/gtk.py +++ b/yin_yang/plugins/gtk.py @@ -4,9 +4,9 @@ from PySide6.QtDBus import QDBusConnection, QDBusMessage -from yin_yang.meta import Desktop -from yin_yang.plugins._plugin import PluginDesktopDependent, Plugin, PluginCommandline -from yin_yang.plugins.system import test_gnome_availability +from ..meta import Desktop +from ._plugin import PluginDesktopDependent, Plugin, PluginCommandline +from .system import test_gnome_availability logger = logging.getLogger(__name__) diff --git a/yin_yang/plugins/icons.py b/yin_yang/plugins/icons.py index cf0a23c5..af503612 100644 --- a/yin_yang/plugins/icons.py +++ b/yin_yang/plugins/icons.py @@ -1,5 +1,5 @@ -from yin_yang.meta import Desktop -from yin_yang.plugins._plugin import PluginDesktopDependent, PluginCommandline +from ..meta import Desktop +from ._plugin import PluginDesktopDependent, PluginCommandline class Icons(PluginDesktopDependent): diff --git a/yin_yang/plugins/konsole.py b/yin_yang/plugins/konsole.py index 05976ee6..055d52cf 100644 --- a/yin_yang/plugins/konsole.py +++ b/yin_yang/plugins/konsole.py @@ -10,7 +10,7 @@ import psutil from PySide6.QtDBus import QDBusConnection, QDBusMessage -from yin_yang.plugins._plugin import Plugin +from ._plugin import Plugin logger = logging.getLogger(__name__) diff --git a/yin_yang/plugins/kvantum.py b/yin_yang/plugins/kvantum.py index 59a0e534..82854a49 100755 --- a/yin_yang/plugins/kvantum.py +++ b/yin_yang/plugins/kvantum.py @@ -1,7 +1,7 @@ import os from pathlib import Path -from yin_yang.plugins._plugin import PluginCommandline +from ._plugin import PluginCommandline class Kvantum(PluginCommandline): diff --git a/yin_yang/plugins/notify.py b/yin_yang/plugins/notify.py index 8941f2f7..12707bbb 100644 --- a/yin_yang/plugins/notify.py +++ b/yin_yang/plugins/notify.py @@ -1,4 +1,4 @@ -from yin_yang.plugins._plugin import PluginCommandline +from ._plugin import PluginCommandline class Notification(PluginCommandline): diff --git a/yin_yang/plugins/only_office.py b/yin_yang/plugins/only_office.py index 84df79e7..9b59dd07 100644 --- a/yin_yang/plugins/only_office.py +++ b/yin_yang/plugins/only_office.py @@ -2,7 +2,7 @@ from os.path import isfile from pathlib import Path -from yin_yang.plugins._plugin import Plugin +from ._plugin import Plugin config_path = f'{Path.home()}/.config/onlyoffice/DesktopEditors.conf' diff --git a/yin_yang/plugins/sound.py b/yin_yang/plugins/sound.py index 1efa492a..a9b3fcc0 100644 --- a/yin_yang/plugins/sound.py +++ b/yin_yang/plugins/sound.py @@ -1,6 +1,6 @@ import subprocess -from yin_yang.plugins._plugin import PluginCommandline +from ._plugin import PluginCommandline class Sound(PluginCommandline): diff --git a/yin_yang/plugins/system.py b/yin_yang/plugins/system.py index b6023aef..153837de 100644 --- a/yin_yang/plugins/system.py +++ b/yin_yang/plugins/system.py @@ -8,8 +8,8 @@ from PySide6.QtCore import QLocale -from yin_yang.meta import Desktop -from yin_yang.plugins._plugin import PluginDesktopDependent, PluginCommandline +from ..meta import Desktop +from ._plugin import PluginDesktopDependent, PluginCommandline logger = logging.getLogger(__name__) diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index 65901853..6b36b28d 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -4,7 +4,7 @@ from PySide6.QtWidgets import QDialogButtonBox, QVBoxLayout, QWidget, QLineEdit from PySide6.QtDBus import QDBusConnection, QDBusMessage -from yin_yang.meta import Desktop +from ..meta import Desktop from ._plugin import PluginDesktopDependent, PluginCommandline, Plugin from .system import test_gnome_availability diff --git a/yin_yang/theme_switcher.py b/yin_yang/theme_switcher.py index 69b274d9..2a177b1f 100755 --- a/yin_yang/theme_switcher.py +++ b/yin_yang/theme_switcher.py @@ -12,11 +12,11 @@ import time from threading import Thread -from yin_yang.plugins.notify import Notification -from yin_yang.plugins.sound import Sound -from yin_yang.daemon_handler import update_times -from yin_yang.meta import PluginKey -from yin_yang.config import config, plugins +from .plugins.notify import Notification +from .plugins.sound import Sound +from .daemon_handler import update_times +from .meta import PluginKey +from .config import config, plugins logger = logging.getLogger(__name__) diff --git a/yin_yang/ui/main_window_connector.py b/yin_yang/ui/main_window_connector.py index 1ae8c5b8..0b9096bd 100755 --- a/yin_yang/ui/main_window_connector.py +++ b/yin_yang/ui/main_window_connector.py @@ -6,12 +6,10 @@ from PySide6.QtGui import QScreen, QColor from PySide6.QtWidgets import QFileDialog, QMessageBox, QDialogButtonBox, QColorDialog,QGroupBox -from yin_yang.ui.main_window import Ui_main_window - -from yin_yang.theme_switcher import set_desired_theme -from yin_yang.meta import ConfigEvent -from yin_yang.meta import PluginKey -from yin_yang.config import config, Modes, plugins, ConfigWatcher +from .main_window import Ui_main_window +from ..theme_switcher import set_desired_theme +from ..meta import ConfigEvent, PluginKey +from ..config import config, Modes, plugins, ConfigWatcher logger = logging.getLogger(__name__) From 6c40711ab6f28e310faa098957fcb954a6243251 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 15:56:56 +0200 Subject: [PATCH 11/35] Fix old path in build_ui --- scripts/build_ui.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build_ui.sh b/scripts/build_ui.sh index aebe92dc..a1293157 100755 --- a/scripts/build_ui.sh +++ b/scripts/build_ui.sh @@ -3,9 +3,9 @@ # resource file pyside6-rcc ./resources/resources.qrc -o ./resources_rc.py # ui file from qt designer -pyside6-uic ./designer/main_window.ui > ./src/ui/main_window.py +pyside6-uic ./designer/main_window.ui > ./yin_yang/ui/main_window.py # extract strings to translate (doesn't work with .pro file unfortunately) -pyside6-lupdate ./designer/main_window.ui ./src/ui/main_window_connector.py \ +pyside6-lupdate ./designer/main_window.ui ./yin_yang/ui/main_window_connector.py \ -ts resources/translations/yin_yang.*.ts -no-obsolete # generate binary translation files pyside6-lrelease ./resources/translations/yin_yang.*.ts From 35752b3797ca4e97a93e02ed5910ad8357a44812 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 16:24:08 +0200 Subject: [PATCH 12/35] Re-added manual buttons --- designer/main_window.ui | 69 ++++++++++--- resources/translations/yin_yang.de_DE.qm | Bin 1908 -> 2146 bytes resources/translations/yin_yang.de_DE.ts | 45 ++++---- resources/translations/yin_yang.nl_NL.qm | Bin 2239 -> 1875 bytes resources/translations/yin_yang.nl_NL.ts | 43 ++++---- scripts/build_ui.sh | 2 +- yin_yang/resources_rc.py | 125 ++++++++++++----------- yin_yang/ui/main_window.py | 39 +++++-- yin_yang/ui/main_window_connector.py | 9 +- 9 files changed, 198 insertions(+), 134 deletions(-) diff --git a/designer/main_window.ui b/designer/main_window.ui index fabc5f4e..237cea31 100755 --- a/designer/main_window.ui +++ b/designer/main_window.ui @@ -276,6 +276,26 @@ + + + + + + + Light + + + + + + + Dark + + + + + + @@ -330,8 +350,8 @@ 0 0 - 523 - 663 + 518 + 676 @@ -340,16 +360,19 @@ - Sample Plugin + Sample Plugin + + + QComboBox::AdjustToContentsOnFirstShow - firefox-compact-light@mozilla.org + firefox-compact-light@mozilla.org @@ -362,7 +385,7 @@ QComboBox::AdjustToContentsOnFirstShow - firefox-compact-dark@mozilla.org + firefox-compact-dark@mozilla.org @@ -402,12 +425,12 @@ setVisible(bool) - 273 - 308 + 289 + 225 - 254 - 379 + 270 + 353 @@ -418,12 +441,12 @@ setVisible(bool) - 114 - 192 + 130 + 109 - 219 - 280 + 235 + 197 @@ -434,8 +457,8 @@ setVisible(bool) - 188 - 153 + 198 + 66 188 @@ -443,5 +466,21 @@ + + btn_enable + toggled(bool) + manual_buttons + setHidden(bool) + + + 109 + 58 + + + 274 + 398 + + + diff --git a/resources/translations/yin_yang.de_DE.qm b/resources/translations/yin_yang.de_DE.qm index d7028c3ab4843b415974f6863e9cf9dea26b25ce..1e075e8ced6e98e285b9d51d2528fc009a188d81 100644 GIT binary patch delta 313 zcmeyu_efxZoZ$inmKEI$49uSyxV&8%7+6ghygFVnFt8{y1pWO2q^C3FEdR{Fz!b*N zX@8P|fn9E*xqR3WwwWxU3=C|m*{vTi12x^`V(2kqU|^KsTF~PTG)$J8`vn(Ja~RKV z#$uqlOy28%gBTbX*6{K5oC1n};pa+!2NY-E*OxpG)YqH|G2l)uvwfnj7bvcCqVunnH5+Ke8nyJ8$IQaszsFeak5>S6JSUi^@7s$?o+az0Bkdj!Es*sbPoLG{X XpQn&mT9Tg&WF{x(tu`Fedg6pn4`oMgUbxA!+~s diff --git a/resources/translations/yin_yang.de_DE.ts b/resources/translations/yin_yang.de_DE.ts index 24f7312f..224e5bb6 100644 --- a/resources/translations/yin_yang.de_DE.ts +++ b/resources/translations/yin_yang.de_DE.ts @@ -4,32 +4,32 @@ MainWindow - + You are using version {} Sie verwenden Version {} - + Dark mode will be active between {} and {}. Dunkler Modus wird zwischen {} und {} aktiv sein. - + Open light wallpaper Öffne helles Hintergrundbild - + Open dark wallpaper Öffne dunkles Hintergrundbild - + The settings have been modified. Do you want to save them? Die Einstellungen wurden geändert. Möchten Sie sie speichern? - + Unsaved changes Ungespeicherte Änderungen @@ -79,37 +79,32 @@ update location automatically - + Position automatisch bestimmen - + + Light + Hell + + + + Dark + Dunkel + + + Make a sound when switching the theme Mache ein Geräusch, wenn das Thema geändert wird - + Send a notification Sende eine Benachrichtigung - + Plugins - - - Sample Plugin - - - - - firefox-compact-light@mozilla.org - - - - - firefox-compact-dark@mozilla.org - - diff --git a/resources/translations/yin_yang.nl_NL.qm b/resources/translations/yin_yang.nl_NL.qm index c0f1709744d5f188837ed951e5626e02444e227c..f04bcedbbbea4ab2d7f5148fb58f73c193de875e 100644 GIT binary patch delta 103 zcmdllc$sg4G-Jm^83hGql~P*<2Bta8ajc~b49wG5_3u|PFt9|k&14B>U|=(tn4_l7 z`hoZQ-yjACh7EjtJ*R-Oz5HD1?-&?Z7xU{&o@ZcStj+`~UA*z&a@NUP+5WJ10F^Q^ GG6Dc$IU2$M delta 428 zcmcc2w_k9AG~Oiq-!U}sOhuW@_avk zkAZ=8G4J)iK@1EG8~FHoPBAdB^zw71zXOVY;MbQt&%nS~oe4DN`^J^aSuGS8!Wi;_ zu!tdvAr%O77*ZGtfMh8{I)g4lCPN+v&>RLfAm$BD%q_@CRS3u_P0!4myn#i0auD0E zdS;-M3qu-EX%SF+8qlZ;pvGh%oeMN55y&b5@>78PJcewbiXsLFpiDkP6;MYG5GFF{ z0eM9X>2Qk_(lU!u)AB2Hlk;;65|c}GQxc1^9dh%lGIMeg_413-*@0Ga=O$+6#g}JJ u-owIK??ll49H4E<3>iST5VBnn-S(W!^o$Z**5{? MainWindow - + You are using version {} U maakt gebruik van versie {} - + Dark mode will be active between {} and {}. Het donkere thema wordt ingeschakeld van {} tot {}. - + Open light wallpaper Lichte achtergrond kiezen - + Open dark wallpaper Donkere achtergrond kiezen - + The settings have been modified. Do you want to save them? De instellingen zijn gewijzigd. Wilt u ze opslaan? - + Unsaved changes Niet-opgeslagen wijzigingen @@ -82,34 +82,29 @@ - + + Light + + + + + Dark + + + + Make a sound when switching the theme Geluid afspelen na instellen van ander thema - + Send a notification Melding tonen - + Plugins Plug-ins - - - Sample Plugin - Voorbeeldplug-in - - - - firefox-compact-light@mozilla.org - firefox-compact-licht@mozilla.org - - - - firefox-compact-dark@mozilla.org - firefox-compact-donker@mozilla.org - diff --git a/scripts/build_ui.sh b/scripts/build_ui.sh index a1293157..773b7ac6 100755 --- a/scripts/build_ui.sh +++ b/scripts/build_ui.sh @@ -1,7 +1,7 @@ #!/bin/bash # resource file -pyside6-rcc ./resources/resources.qrc -o ./resources_rc.py +pyside6-rcc ./resources/resources.qrc -o ./yin_yang/resources_rc.py # ui file from qt designer pyside6-uic ./designer/main_window.ui > ./yin_yang/ui/main_window.py # extract strings to translate (doesn't work with .pro file unfortunately) diff --git a/yin_yang/resources_rc.py b/yin_yang/resources_rc.py index 94afa888..64abef7b 100644 --- a/yin_yang/resources_rc.py +++ b/yin_yang/resources_rc.py @@ -1,25 +1,26 @@ # Resource object code (Python 3) # Created by: object code -# Created by: The Resource Compiler for Qt version 6.4.1 +# Created by: The Resource Compiler for Qt version 6.5.0 # WARNING! All changes made in this file will be lost! from PySide6 import QtCore qt_resource_data = b"\ -\x00\x00\x07\xfd\ +\x00\x00\x08b\ <\ \xb8d\x18\xca\xef\x9c\x95\xcd!\x1c\xbf`\xa1\xbd\xdd\xa7\ -\x00\x00\x00\x05de_DEB\x00\x00\x00\x90\x00\x0a\ -KE\x00\x00\x04\xd7\x00J\x88\xea\x00\x00\x03\xf3\x00l\ -\xa7\xf3\x00\x00\x02V\x00\x89?\xc9\x00\x00\x06\xc1\x00\xb6\ +\x00\x00\x00\x05de_DEB\x00\x00\x00\xa0\x00\x04\ +\xa8\x8b\x00\x00\x03\xf3\x00\x0aKE\x00\x00\x054\x00J\ +\x88\xea\x00\x00\x04#\x00R\xfd\xf4\x00\x00\x04\x97\x00l\ +\xa7\xf3\x00\x00\x02V\x00\x89?\xc9\x00\x00\x07\x1e\x00\xb6\ \xd1\xae\x00\x00\x00\x00\x03$u=\x00\x00\x02\xb6\x03^\ -\x05u\x00\x00\x03\x8c\x05/\xdfz\x00\x00\x04g\x06\x99\ -\x04U\x00\x00\x06N\x07;\xe0\x03\x00\x00\x05|\x0a\x00\ +\x05u\x00\x00\x03\x8c\x05/\xdfz\x00\x00\x04\xc4\x06\x99\ +\x04U\x00\x00\x06\xab\x07;\xe0\x03\x00\x00\x05\xd9\x0a\x00\ \x8c2\x00\x00\x01\x18\x0a\xa0\x8cG\x00\x00\x03\x1d\x0b\x0b\ -\xe8\x0a\x00\x00\x04&\x0c\xbb\x01s\x00\x00\x06\x0c\x0d\xd7\ -\xfdR\x00\x00\x00\xac\x0e\x0e\x8c\xca\x00\x00\x04\x97\x0f\x0a\ -g\xee\x00\x00\x05\xa3\x0f/\x19\xcf\x00\x00\x01\x83i\x00\ -\x00\x07B\x03\x00\x00\x00b\x00D\x00u\x00n\x00k\ +\xe8\x0a\x00\x00\x04V\x0c\xbb\x01s\x00\x00\x06i\x0d\xd7\ +\xfdR\x00\x00\x00\xac\x0e\x0e\x8c\xca\x00\x00\x04\xf4\x0f\x0a\ +g\xee\x00\x00\x06\x00\x0f/\x19\xcf\x00\x00\x01\x83i\x00\ +\x00\x07\x97\x03\x00\x00\x00b\x00D\x00u\x00n\x00k\ \x00l\x00e\x00r\x00 \x00M\x00o\x00d\x00u\ \x00s\x00 \x00w\x00i\x00r\x00d\x00 \x00z\ \x00w\x00i\x00s\x00c\x00h\x00e\x00n\x00 \ @@ -82,6 +83,9 @@ \x00i\x00t\x00r\x00a\x00u\x00m\x08\x00\x00\x00\ \x00\x06\x00\x00\x00\x0fCustom Sch\ edule\x07\x00\x00\x00\x0bmain_w\ +indow\x01\x03\x00\x00\x00\x0c\x00D\x00u\x00\ +n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x04Dark\x07\x00\x00\x00\x0bmain_w\ indow\x01\x03\x00\x00\x00\x0e\x00D\x00u\x00\ n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\ \x00\x00\x05Dark:\x07\x00\x00\x00\x0bmai\ @@ -89,53 +93,56 @@ \x00r\x00e\x00i\x00t\x00e\x00n\x00g\x00r\ \x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x09\ Latitude:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x0a\x00\ -H\x00e\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\ -\x00\x00\x06Light:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x16\x00\ -L\x00\xe4\x00n\x00g\x00e\x00n\x00g\x00r\x00\ -a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aL\ -ongitude:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00`\x00\ -M\x00a\x00c\x00h\x00e\x00 \x00e\x00i\x00\ -n\x00 \x00G\x00e\x00r\x00\xe4\x00u\x00s\x00\ -c\x00h\x00,\x00 \x00w\x00e\x00n\x00n\x00\ - \x00d\x00a\x00s\x00 \x00T\x00h\x00e\x00\ -m\x00a\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00\ -e\x00r\x00t\x00 \x00w\x00i\x00r\x00d\x08\ -\x00\x00\x00\x00\x06\x00\x00\x00%Make a \ -sound when switc\ -hing the theme\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Pl\ -ugins\x07\x00\x00\x00\x0bmain_w\ -indow\x01\x03\x00\x00\x006\x00S\x00e\x00\ -n\x00d\x00e\x00 \x00e\x00i\x00n\x00e\x00\ - \x00B\x00e\x00n\x00a\x00c\x00h\x00r\x00\ -i\x00c\x00h\x00t\x00i\x00g\x00u\x00n\x00\ -g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13Send \ -a notification\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x00\x1a\x00E\x00i\x00n\x00s\x00t\x00e\ -\x00l\x00l\x00u\x00n\x00g\x00e\x00n\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x08Settings\ +in_window\x01\x03\x00\x00\x00\x08\x00\ +H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x05Light\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00\x0a\x00H\x00e\ +\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x06\ +Light:\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00\x16\x00L\x00\xe4\ +\x00n\x00g\x00e\x00n\x00g\x00r\x00a\x00d\ +\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aLong\ +itude:\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00`\x00M\x00a\ +\x00c\x00h\x00e\x00 \x00e\x00i\x00n\x00 \ +\x00G\x00e\x00r\x00\xe4\x00u\x00s\x00c\x00h\ +\x00,\x00 \x00w\x00e\x00n\x00n\x00 \x00d\ +\x00a\x00s\x00 \x00T\x00h\x00e\x00m\x00a\ +\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00e\x00r\ +\x00t\x00 \x00w\x00i\x00r\x00d\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00%Make a sou\ +nd when switchin\ +g the theme\x07\x00\x00\x00\x0b\ +main_window\x01\x03\xff\xff\xff\ +\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Plugi\ +ns\x07\x00\x00\x00\x0bmain_wind\ +ow\x01\x03\x00\x00\x006\x00S\x00e\x00n\x00d\ +\x00e\x00 \x00e\x00i\x00n\x00e\x00 \x00B\ +\x00e\x00n\x00a\x00c\x00h\x00r\x00i\x00c\ +\x00h\x00t\x00i\x00g\x00u\x00n\x00g\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x13Send a n\ +otification\x07\x00\x00\x00\x0b\ +main_window\x01\x03\x00\x00\x00\ +\x1a\x00E\x00i\x00n\x00s\x00t\x00e\x00l\x00\ +l\x00u\x00n\x00g\x00e\x00n\x08\x00\x00\x00\x00\ +\x06\x00\x00\x00\x08Settings\x07\x00\x00\ +\x00\x0bmain_window\x01\x03\x00\ +\x00\x00B\x00S\x00o\x00n\x00n\x00e\x00n\x00\ +a\x00u\x00f\x00g\x00a\x00n\x00g\x00 \x00\ +b\x00i\x00s\x00 \x00S\x00o\x00n\x00n\x00\ +e\x00n\x00u\x00n\x00t\x00e\x00r\x00g\x00\ +a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11S\ +unset to Sunrise\ \x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00B\x00S\x00o\x00n\x00n\x00e\ -\x00n\x00a\x00u\x00f\x00g\x00a\x00n\x00g\ -\x00 \x00b\x00i\x00s\x00 \x00S\x00o\x00n\ -\x00n\x00e\x00n\x00u\x00n\x00t\x00e\x00r\ -\x00g\x00a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\ -\x00\x11Sunset to Sunr\ -ise\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\x00\x00\x00D\x00S\x00t\x00a\x00\ -n\x00d\x00o\x00r\x00t\x00 \x00a\x00u\x00\ -t\x00o\x00m\x00a\x00t\x00i\x00s\x00c\x00\ -h\x00 \x00a\x00k\x00t\x00u\x00a\x00l\x00\ -i\x00s\x00i\x00e\x00r\x00e\x00n\x08\x00\x00\ -\x00\x00\x06\x00\x00\x00\x1dupdate lo\ -cation automatic\ -ally\x07\x00\x00\x00\x0bmain_wi\ -ndow\x01\x88\x00\x00\x00\x02\x01\x01\ +\x01\x03\x00\x00\x00<\x00P\x00o\x00s\x00i\x00t\ +\x00i\x00o\x00n\x00 \x00a\x00u\x00t\x00o\ +\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00 \ +\x00b\x00e\x00s\x00t\x00i\x00m\x00m\x00e\ +\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x1dupda\ +te location auto\ +matically\x07\x00\x00\x00\x0bma\ +in_window\x01\x88\x00\x00\x00\x02\x01\ +\x01\ \x00\x00\x07\x22\ \x00\ \x00\x1dUx\xda\xcdYKs\xdb6\x10\xbe\xe7Wp\ @@ -282,8 +289,8 @@ \x00\x00\x00\x10\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00.\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x87W\x9b\xe0\xc2\ -\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x08\x01\ +\x00\x00\x01\x88\x15}\xd2\xab\ +\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x08f\ \x00\x00\x01\x84\x01\xd5\x8cC\ " diff --git a/yin_yang/ui/main_window.py b/yin_yang/ui/main_window.py index 865f1d9d..f62ae5d4 100644 --- a/yin_yang/ui/main_window.py +++ b/yin_yang/ui/main_window.py @@ -3,7 +3,7 @@ ################################################################################ ## Form generated from reading UI file 'main_window.ui' ## -## Created by: Qt User Interface Compiler version 6.4.1 +## Created by: Qt User Interface Compiler version 6.5.0 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ @@ -18,9 +18,9 @@ from PySide6.QtWidgets import (QAbstractButton, QApplication, QCheckBox, QComboBox, QDialogButtonBox, QDoubleSpinBox, QFormLayout, QFrame, QGroupBox, QHBoxLayout, QLabel, QMainWindow, - QRadioButton, QScrollArea, QSizePolicy, QSpacerItem, - QStatusBar, QTabWidget, QTimeEdit, QVBoxLayout, - QWidget) + QPushButton, QRadioButton, QScrollArea, QSizePolicy, + QSpacerItem, QStatusBar, QTabWidget, QTimeEdit, + QVBoxLayout, QWidget) import resources_rc class Ui_main_window(object): @@ -210,6 +210,25 @@ def setupUi(self, main_window): self.settings_layout.addWidget(self.schedule_settings) + self.manual_buttons = QWidget(self.settings) + self.manual_buttons.setObjectName(u"manual_buttons") + self.horizontalLayout_3 = QHBoxLayout(self.manual_buttons) + self.horizontalLayout_3.setSpacing(6) + self.horizontalLayout_3.setContentsMargins(11, 11, 11, 11) + self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") + self.button_light = QPushButton(self.manual_buttons) + self.button_light.setObjectName(u"button_light") + + self.horizontalLayout_3.addWidget(self.button_light) + + self.button_dark = QPushButton(self.manual_buttons) + self.button_dark.setObjectName(u"button_dark") + + self.horizontalLayout_3.addWidget(self.button_dark) + + + self.settings_layout.addWidget(self.manual_buttons) + self.toggle_sound = QCheckBox(self.settings) self.toggle_sound.setObjectName(u"toggle_sound") @@ -243,7 +262,7 @@ def setupUi(self, main_window): self.plugins_scroll.setWidgetResizable(True) self.plugins_scroll_content = QWidget() self.plugins_scroll_content.setObjectName(u"plugins_scroll_content") - self.plugins_scroll_content.setGeometry(QRect(0, 0, 523, 663)) + self.plugins_scroll_content.setGeometry(QRect(0, 0, 518, 676)) self.plugins_scroll_content_layout = QVBoxLayout(self.plugins_scroll_content) self.plugins_scroll_content_layout.setSpacing(6) self.plugins_scroll_content_layout.setContentsMargins(11, 11, 11, 11) @@ -253,13 +272,16 @@ def setupUi(self, main_window): self.horizontalLayout.setObjectName(u"horizontalLayout") self.samplePluginGroupBox = QGroupBox(self.plugins_scroll_content) self.samplePluginGroupBox.setObjectName(u"samplePluginGroupBox") + self.samplePluginGroupBox.setTitle(u"Sample Plugin") self.horizontalLayout_2 = QHBoxLayout(self.samplePluginGroupBox) self.horizontalLayout_2.setSpacing(6) self.horizontalLayout_2.setContentsMargins(11, 11, 11, 11) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.comboBox = QComboBox(self.samplePluginGroupBox) self.comboBox.setObjectName(u"comboBox") + self.comboBox.setCurrentText(u"") self.comboBox.setSizeAdjustPolicy(QComboBox.AdjustToContentsOnFirstShow) + self.comboBox.setPlaceholderText(u"firefox-compact-light@mozilla.org") self.horizontalLayout_2.addWidget(self.comboBox) @@ -267,6 +289,7 @@ def setupUi(self, main_window): self.comboBox_2.setObjectName(u"comboBox_2") self.comboBox_2.setCurrentText(u"") self.comboBox_2.setSizeAdjustPolicy(QComboBox.AdjustToContentsOnFirstShow) + self.comboBox_2.setPlaceholderText(u"firefox-compact-dark@mozilla.org") self.horizontalLayout_2.addWidget(self.comboBox_2) @@ -299,6 +322,7 @@ def setupUi(self, main_window): self.btn_sun.toggled.connect(self.location.setVisible) self.btn_schedule.toggled.connect(self.time.setVisible) self.btn_enable.toggled.connect(self.schedule_settings.setVisible) + self.btn_enable.toggled.connect(self.manual_buttons.setHidden) self.tab_widget.setCurrentIndex(1) @@ -315,12 +339,11 @@ def retranslateUi(self, main_window): self.label_longitude.setText(QCoreApplication.translate("main_window", u"Longitude:", None)) self.label_latitude.setText(QCoreApplication.translate("main_window", u"Latitude:", None)) self.btn_location.setText(QCoreApplication.translate("main_window", u"update location automatically", None)) + self.button_light.setText(QCoreApplication.translate("main_window", u"Light", None)) + self.button_dark.setText(QCoreApplication.translate("main_window", u"Dark", None)) self.toggle_sound.setText(QCoreApplication.translate("main_window", u"Make a sound when switching the theme", None)) self.toggle_notification.setText(QCoreApplication.translate("main_window", u"Send a notification", None)) self.tab_widget.setTabText(self.tab_widget.indexOf(self.settings), QCoreApplication.translate("main_window", u"Settings", None)) - self.samplePluginGroupBox.setTitle(QCoreApplication.translate("main_window", u"Sample Plugin", None)) - self.comboBox.setPlaceholderText(QCoreApplication.translate("main_window", u"firefox-compact-light@mozilla.org", None)) - self.comboBox_2.setPlaceholderText(QCoreApplication.translate("main_window", u"firefox-compact-dark@mozilla.org", None)) self.tab_widget.setTabText(self.tab_widget.indexOf(self.plugins), QCoreApplication.translate("main_window", u"Plugins", None)) pass # retranslateUi diff --git a/yin_yang/ui/main_window_connector.py b/yin_yang/ui/main_window_connector.py index 0b9096bd..e920edb6 100755 --- a/yin_yang/ui/main_window_connector.py +++ b/yin_yang/ui/main_window_connector.py @@ -2,12 +2,12 @@ from typing import cast from PySide6 import QtWidgets -from PySide6.QtCore import QStandardPaths +from PySide6.QtCore import QStandardPaths, Slot from PySide6.QtGui import QScreen, QColor from PySide6.QtWidgets import QFileDialog, QMessageBox, QDialogButtonBox, QColorDialog,QGroupBox from .main_window import Ui_main_window -from ..theme_switcher import set_desired_theme +from ..theme_switcher import set_desired_theme, set_mode from ..meta import ConfigEvent, PluginKey from ..config import config, Modes, plugins, ConfigWatcher @@ -71,6 +71,7 @@ def load(self): # set the correct mode mode = config.mode self.ui.btn_enable.setChecked(mode != Modes.MANUAL) + self.ui.manual_buttons.setVisible(mode == Modes.MANUAL) if mode == Modes.FOLLOW_SUN: self.ui.time.setVisible(False) @@ -190,6 +191,10 @@ def setup_config_sync(self): self.ui.toggle_notification.toggled.connect( lambda enabled: config.update_plugin_key('notification', PluginKey.ENABLED, enabled)) + # connect manual theme buttons + self.ui.button_light.clicked.connect(lambda: set_mode(False)) + self.ui.button_dark.clicked.connect(lambda: set_mode(True)) + def save_mode(self): if not self.ui.btn_enable.isChecked(): config.mode = Modes.MANUAL From 4ca1469ba85214e491fe65702108f7c3611f951e Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 16:25:39 +0200 Subject: [PATCH 13/35] Fix import of communication script --- tests/test_communication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_communication.py b/tests/test_communication.py index 32e52259..6c8d0aa2 100644 --- a/tests/test_communication.py +++ b/tests/test_communication.py @@ -5,7 +5,7 @@ from datetime import datetime, time from subprocess import Popen, PIPE -import communicate +from yin_yang import communicate from yin_yang.meta import PluginKey from yin_yang.config import config from yin_yang.theme_switcher import should_be_dark From 51aa9c9c7ce64e36a680fe3906f65f96f6c6f076 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 16:49:36 +0200 Subject: [PATCH 14/35] Add support for cinnamon (untested) --- yin_yang/config.py | 2 ++ yin_yang/meta.py | 1 + yin_yang/plugins/gtk.py | 9 +++++++++ yin_yang/plugins/icons.py | 9 +++++++++ yin_yang/plugins/system.py | 9 +++++++++ yin_yang/plugins/wallpaper.py | 7 +++++++ 6 files changed, 37 insertions(+) diff --git a/yin_yang/config.py b/yin_yang/config.py index b63c49a3..12486eda 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -155,6 +155,8 @@ def get_desktop() -> Desktop: return Desktop.XFCE case 'mate': return Desktop.MATE + case 'X-Cinnamon': + return Desktop.CINNAMON case 'sway' | 'hyprland': return Desktop.GNOME case _: diff --git a/yin_yang/meta.py b/yin_yang/meta.py index d824f315..cbfe421f 100644 --- a/yin_yang/meta.py +++ b/yin_yang/meta.py @@ -15,6 +15,7 @@ class Desktop(Enum): XFCE = 'xfce' UNKNOWN = 'unknown' MATE = 'mate' + CINNAMON = 'cinnamon' class PluginKey(Enum): diff --git a/yin_yang/plugins/gtk.py b/yin_yang/plugins/gtk.py index 79b36759..bfcf3451 100755 --- a/yin_yang/plugins/gtk.py +++ b/yin_yang/plugins/gtk.py @@ -30,6 +30,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Mate()) case Desktop.XFCE: super().__init__(_Xfce()) + case Desktop.CINNAMON: + super().__init__(_Cinnamon()) case _: super().__init__(None) @@ -96,3 +98,10 @@ def __init__(self): @property def available(self) -> bool: return self.check_command(['dconf', 'help']) + + +class _Cinnamon(PluginCommandline): + def __init__(self): + super().__init__(['gsettings', 'set', 'org.cinnamon.desktop.interface', 'gtk-theme', '\"{theme}\"']) + self.theme_light = 'Adwaita' + self.theme_dark = 'Adwaita-dark' diff --git a/yin_yang/plugins/icons.py b/yin_yang/plugins/icons.py index af503612..bda6b4e0 100644 --- a/yin_yang/plugins/icons.py +++ b/yin_yang/plugins/icons.py @@ -7,6 +7,8 @@ def __init__(self, desktop: Desktop): match desktop: case Desktop.MATE: super().__init__(_Mate()) + case Desktop.CINNAMON: + super().__init__(_Cinnamon()) case _: super().__init__(None) @@ -20,3 +22,10 @@ def __init__(self): @property def available(self): return self.check_command(['dconf', 'help']) + + +class _Cinnamon(PluginCommandline): + def __init__(self): + super().__init__(['gsettings', 'set', 'org.cinnamon.desktop.interface', 'icon-theme', '\"{theme}\"']) + self.theme_light = 'Mint-X' + self.theme_dark = 'gnome' diff --git a/yin_yang/plugins/system.py b/yin_yang/plugins/system.py index 153837de..60aa9248 100644 --- a/yin_yang/plugins/system.py +++ b/yin_yang/plugins/system.py @@ -29,6 +29,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Gnome()) case Desktop.MATE: super().__init__(_Mate()) + case Desktop.CINNAMON: + super().__init__(_Cinnamon()) case _: super().__init__(None) @@ -159,3 +161,10 @@ def available_themes(self) -> dict: @property def available(self): return self.check_command(['dconf', 'help']) + + +class _Cinnamon(PluginCommandline): + def __init__(self): + super().__init__(['gsettings', 'set', 'org.cinnamon.theme', 'name', '\"{theme}\"']) + self.theme_light = 'Mint-X-Teal' + self.theme_dark = 'Mint-Y-Dark-Brown' diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index 6b36b28d..d5708124 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -22,6 +22,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Gnome()) case Desktop.XFCE: super().__init__(_Xfce()) + case Desktop.CINNAMON: + super().__init__(_Cinnamon()) case _: super().__init__(None) @@ -97,3 +99,8 @@ def __init__(self): monitor = next(p for p in properties.split('\\n') if p.endswith('/workspace0/last-image')) super().__init__(['xfconf-query', '-c', 'xfce4-desktop', '-p', monitor, '-s', '{theme}']) + + +class _Cinnamon(PluginCommandline): + def __init__(self): + super().__init__(['gsettings', 'set', 'org.cinnamon.background', 'picture-ui', 'file://\"{theme}\"']) From bbee96bba94b304934c3ae997c8b818ceeba6ba1 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 13 May 2023 17:34:01 +0200 Subject: [PATCH 15/35] Fix casing --- yin_yang/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yin_yang/config.py b/yin_yang/config.py index 12486eda..0d8fd1d3 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -155,7 +155,7 @@ def get_desktop() -> Desktop: return Desktop.XFCE case 'mate': return Desktop.MATE - case 'X-Cinnamon': + case 'x-cinnamon': return Desktop.CINNAMON case 'sway' | 'hyprland': return Desktop.GNOME From 7a67616a8280fa985046c0902fe70046689ba563 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sun, 14 May 2023 11:31:16 +0200 Subject: [PATCH 16/35] Fix availability checks --- yin_yang/plugins/gtk.py | 4 ++++ yin_yang/plugins/icons.py | 5 +++++ yin_yang/plugins/system.py | 4 ++++ yin_yang/plugins/wallpaper.py | 10 +++++----- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/yin_yang/plugins/gtk.py b/yin_yang/plugins/gtk.py index bfcf3451..7dad089c 100755 --- a/yin_yang/plugins/gtk.py +++ b/yin_yang/plugins/gtk.py @@ -105,3 +105,7 @@ def __init__(self): super().__init__(['gsettings', 'set', 'org.cinnamon.desktop.interface', 'gtk-theme', '\"{theme}\"']) self.theme_light = 'Adwaita' self.theme_dark = 'Adwaita-dark' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) diff --git a/yin_yang/plugins/icons.py b/yin_yang/plugins/icons.py index bda6b4e0..3121e6c4 100644 --- a/yin_yang/plugins/icons.py +++ b/yin_yang/plugins/icons.py @@ -1,3 +1,4 @@ +from .system import test_gnome_availability from ..meta import Desktop from ._plugin import PluginDesktopDependent, PluginCommandline @@ -29,3 +30,7 @@ def __init__(self): super().__init__(['gsettings', 'set', 'org.cinnamon.desktop.interface', 'icon-theme', '\"{theme}\"']) self.theme_light = 'Mint-X' self.theme_dark = 'gnome' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) diff --git a/yin_yang/plugins/system.py b/yin_yang/plugins/system.py index 60aa9248..f5c2710d 100644 --- a/yin_yang/plugins/system.py +++ b/yin_yang/plugins/system.py @@ -168,3 +168,7 @@ def __init__(self): super().__init__(['gsettings', 'set', 'org.cinnamon.theme', 'name', '\"{theme}\"']) self.theme_light = 'Mint-X-Teal' self.theme_dark = 'Mint-Y-Dark-Brown' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index d5708124..7be015c8 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -27,10 +27,6 @@ def __init__(self, desktop: Desktop): case _: super().__init__(None) - @property - def available(self) -> bool: - return self.strategy is not None - def get_input(self, widget): widgets = [] @@ -103,4 +99,8 @@ def __init__(self): class _Cinnamon(PluginCommandline): def __init__(self): - super().__init__(['gsettings', 'set', 'org.cinnamon.background', 'picture-ui', 'file://\"{theme}\"']) + super().__init__(['gsettings', 'set', 'org.cinnamon.desktop.background', 'picture-uri', 'file://\"{theme}\"']) + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) From a1369e129d400a040467f762850c3eb68227964d Mon Sep 17 00:00:00 2001 From: l0drex Date: Sun, 14 May 2023 16:02:10 +0200 Subject: [PATCH 17/35] Add system tray icon --- resources/translations/yin_yang.de_DE.qm | Bin 2146 -> 1434 bytes resources/translations/yin_yang.de_DE.ts | 48 ++--- resources/translations/yin_yang.nl_NL.qm | Bin 1875 -> 1046 bytes resources/translations/yin_yang.nl_NL.ts | 48 ++--- scripts/build_ui.sh | 2 +- yin_yang/__main__.py | 59 ++++-- yin_yang/resources_rc.py | 225 +++++++++-------------- yin_yang/ui/main_window_connector.py | 2 +- 8 files changed, 164 insertions(+), 220 deletions(-) diff --git a/resources/translations/yin_yang.de_DE.qm b/resources/translations/yin_yang.de_DE.qm index 1e075e8ced6e98e285b9d51d2528fc009a188d81..b68e01df55168196a9175bd14bca2752bc5f831d 100644 GIT binary patch delta 272 zcmaDPFpGPFTzvxr%ZhFW28L@4tUW9Y3@is3xV&8%7?{KvygFVnFfg()1pWO2q^lS@ z?N0*b8JXi)OM&Y1S@rK%0mYZI&14B>U|{ZJw|>A3)VGH#^Ye3{x+<;(J?=nt4BXr= zxPa;`d3G}v1J(KP@%5Yn@~`uArN3ifU}t)q2~_=l^F!t;mdODuEERGLkqns(c?=3b zIuS^x16kh~(tt3JA(bJI17s!}5cB#Mq~<9^W&&|yUOGEaguS@3xTGktk`d?*20jKS ZpmLxFh7=TSEPK0pJ33ap)U==(&}1UV;LUv z0!G%c!MCY3_kGV{pBSk^hat^G#p~)ZBdx^eLfwg0#aie}ktp96OHw$?vFb=#aUx|P z);EL`xIC(5=2zw&72HvQ8zwnJb_SoY!hgWd!jk+)+>pI)(PGGyoSS_5+?E*j;btUG z-E0xaHB1u6_ghX&Mu&l29s)C}eLJHes6&xbQnh+dTPR;Oz4&OXF1Mhps97sQbBcXD zqoGOLOgy0?vyHxIqCXfne#HDLGv@J!8%jM}Zc1(q+Uo3VFY=zFwkaiuMH~ukQesc8)rRMn_O~^S#(=!WFsczJu$z(3 zL}pyZ8-eNWie=9UnoEp6q(?w diff --git a/resources/translations/yin_yang.de_DE.ts b/resources/translations/yin_yang.de_DE.ts index 224e5bb6..9f4e7060 100644 --- a/resources/translations/yin_yang.de_DE.ts +++ b/resources/translations/yin_yang.de_DE.ts @@ -1,39 +1,6 @@ - - MainWindow - - - You are using version {} - Sie verwenden Version {} - - - - Dark mode will be active between {} and {}. - Dunkler Modus wird zwischen {} und {} aktiv sein. - - - - Open light wallpaper - Öffne helles Hintergrundbild - - - - Open dark wallpaper - Öffne dunkles Hintergrundbild - - - - The settings have been modified. Do you want to save them? - Die Einstellungen wurden geändert. Möchten Sie sie speichern? - - - - Unsaved changes - Ungespeicherte Änderungen - - main_window @@ -107,4 +74,19 @@ + + systray + + + Open Yin Yang + Context menu action in the systray + Yin Yang öffnen + + + + Quit + Context menu action in the systray + Beenden + + diff --git a/resources/translations/yin_yang.nl_NL.qm b/resources/translations/yin_yang.nl_NL.qm index f04bcedbbbea4ab2d7f5148fb58f73c193de875e..065f4499b54ddc4b286ea96834c0b18283b04e02 100644 GIT binary patch delta 106 zcmcc2H;rS0bX)`jm$xee1LGkEuZ~v?3=B7z<5)|9bSJC+{VJfiAKOfpPzDBOWp?Wa z%nS@n@mvdf+=228+}tm?fb!ftyBUjt;*a_GdQJiP4g6f`?|}SinLtg`Hg98|%M1V; CSQu^q literal 1875 zcmaJ>J!lkB5S}xCdWngm$R$`jK`Sv45s|2fF(LjW8jLZDpgwP3cGuf`8+PAjF(G}5 zSSko96bn1C5<$d1AYx@D+6ZEyg0S;MjS{^sYKnQ!L!OQ*E@W99zaJ-grB zdi?t1QzF`=gCQ(SR6IXI)cTIjEqxxyNZvNM{Gl&kYG6< zQZ8O%DnmkAjR0?g=5W$j7ibax20ARyr~b_xTsyw~!!oLfYUn7D`avLWDAS8>CF3%i?i_H zFoaYF!K|EBQJ$AWGzM*skL?P?Ro_R5ePbUxt&hNWJ+rYB2cfWWPH1c$1r%iIAhV3Q#I|oE{|S6oaIQ0M4)+nlW<-{8S=gm(2uVgtBryUPb1I7c zkV%&3aH6T~18a!3wjCq@FufU?fzw(m{9DOp;`N?NOjwo1FWZ!&5~**>9w0G}&MHWL zGi|V3&#{f&YIg&lS7{U$0!t7c z0ulo*Mn~{njg}gBIhAT66Zee+=?Hh(5X^G6Z(LR|vqT&wm{O^S7RqYLwXM}RH>cZZ z!a{S=Gq&k7qa71L;`-Wl!8$VZ(YVF$SS8n@;vv_}uN{*LXr$1gK{uCCmr& - - MainWindow - - - You are using version {} - U maakt gebruik van versie {} - - - - Dark mode will be active between {} and {}. - Het donkere thema wordt ingeschakeld van {} tot {}. - - - - Open light wallpaper - Lichte achtergrond kiezen - - - - Open dark wallpaper - Donkere achtergrond kiezen - - - - The settings have been modified. Do you want to save them? - De instellingen zijn gewijzigd. Wilt u ze opslaan? - - - - Unsaved changes - Niet-opgeslagen wijzigingen - - main_window @@ -107,4 +74,19 @@ Plug-ins + + systray + + + Open Yin Yang + Context menu action in the systray + + + + + Quit + Context menu action in the systray + + + diff --git a/scripts/build_ui.sh b/scripts/build_ui.sh index 773b7ac6..ef81ce89 100755 --- a/scripts/build_ui.sh +++ b/scripts/build_ui.sh @@ -5,7 +5,7 @@ pyside6-rcc ./resources/resources.qrc -o ./yin_yang/resources_rc.py # ui file from qt designer pyside6-uic ./designer/main_window.ui > ./yin_yang/ui/main_window.py # extract strings to translate (doesn't work with .pro file unfortunately) -pyside6-lupdate ./designer/main_window.ui ./yin_yang/ui/main_window_connector.py \ +pyside6-lupdate ./designer/main_window.ui ./yin_yang/* \ -ts resources/translations/yin_yang.*.ts -no-obsolete # generate binary translation files pyside6-lrelease ./resources/translations/yin_yang.*.ts diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py index dfc3569d..2e9df8d4 100755 --- a/yin_yang/__main__.py +++ b/yin_yang/__main__.py @@ -7,7 +7,9 @@ from pathlib import Path from PySide6 import QtWidgets -from PySide6.QtCore import QTranslator, QLibraryInfo, QLocale +from PySide6.QtCore import QTranslator, QLibraryInfo, QLocale, QObject +from PySide6.QtGui import QIcon +from PySide6.QtWidgets import QSystemTrayIcon, QMenu from systemd import journal from yin_yang import daemon_handler @@ -47,21 +49,36 @@ def setup_logger(use_systemd_journal: bool): ) logging.root.addHandler(file_handler) +def systray_icon_clicked(reason: QSystemTrayIcon.ActivationReason): + match reason: + case QSystemTrayIcon.ActivationReason.MiddleClick: + theme_switcher.set_mode(not config.dark_mode) + case QSystemTrayIcon.ActivationReason.Trigger: + window.show() + # using ArgumentParser for parsing arguments parser = ArgumentParser() -parser.add_argument("-t", "--toggle", - help="toggles Yin-Yang", - action="store_true") -parser.add_argument("--systemd", help="uses systemd journal handler and applies desired theme", action='store_true') +parser.add_argument('-t', '--toggle', + help='toggles Yin-Yang', + action='store_true') +parser.add_argument('--systemd', help='uses systemd journal handler and applies desired theme', action='store_true') arguments = parser.parse_args() setup_logger(arguments.systemd) -# checks whether $ yin-yang is run without args -if len(sys.argv) == 1: +if arguments.toggle: + # terminate any running instances + config.running = False + config.mode = Modes.MANUAL + theme_switcher.set_mode(not config.dark_mode) + +elif arguments.systemd: + theme_switcher.set_desired_theme() + +else: + # load GUI config.add_event_listener(ConfigEvent.SAVE, daemon_handler.watcher) config.add_event_listener(ConfigEvent.CHANGE, daemon_handler.watcher) - # load GUI app = QtWidgets.QApplication(sys.argv) # load translation @@ -89,15 +106,23 @@ def setup_logger(use_systemd_journal: bool): logger.error(str(e)) print('Error while loading translation. Using default language.') + # show systray icon + if QSystemTrayIcon.isSystemTrayAvailable(): + app.setQuitOnLastWindowClosed(False) + + icon = QSystemTrayIcon(QIcon(u':icons/logo'), app) + icon.activated.connect(systray_icon_clicked) + icon.setToolTip('Yin & Yang') + + menu = QMenu('Yin & Yang') + menu.addAction(app.translate('systray', 'Open Yin Yang', 'Context menu action in the systray'), lambda: window.show()) + menu.addAction(QIcon.fromTheme('application-exit'), app.translate('systray', 'Quit', 'Context menu action in the systray'), app.quit) + + icon.setContextMenu(menu) + icon.show() + else: + logger.debug('System tray is unsupported') + window = main_window_connector.MainWindow() window.show() sys.exit(app.exec()) - -if arguments.toggle: - # terminate any running instances - config.running = False - config.mode = Modes.MANUAL - theme_switcher.set_mode(not config.dark_mode) - -if arguments.systemd: - theme_switcher.set_desired_theme() diff --git a/yin_yang/resources_rc.py b/yin_yang/resources_rc.py index 64abef7b..318ae0e8 100644 --- a/yin_yang/resources_rc.py +++ b/yin_yang/resources_rc.py @@ -6,143 +6,98 @@ from PySide6 import QtCore qt_resource_data = b"\ -\x00\x00\x08b\ +\x00\x00\x05\x9a\ <\ \xb8d\x18\xca\xef\x9c\x95\xcd!\x1c\xbf`\xa1\xbd\xdd\xa7\ -\x00\x00\x00\x05de_DEB\x00\x00\x00\xa0\x00\x04\ -\xa8\x8b\x00\x00\x03\xf3\x00\x0aKE\x00\x00\x054\x00J\ -\x88\xea\x00\x00\x04#\x00R\xfd\xf4\x00\x00\x04\x97\x00l\ -\xa7\xf3\x00\x00\x02V\x00\x89?\xc9\x00\x00\x07\x1e\x00\xb6\ -\xd1\xae\x00\x00\x00\x00\x03$u=\x00\x00\x02\xb6\x03^\ -\x05u\x00\x00\x03\x8c\x05/\xdfz\x00\x00\x04\xc4\x06\x99\ -\x04U\x00\x00\x06\xab\x07;\xe0\x03\x00\x00\x05\xd9\x0a\x00\ -\x8c2\x00\x00\x01\x18\x0a\xa0\x8cG\x00\x00\x03\x1d\x0b\x0b\ -\xe8\x0a\x00\x00\x04V\x0c\xbb\x01s\x00\x00\x06i\x0d\xd7\ -\xfdR\x00\x00\x00\xac\x0e\x0e\x8c\xca\x00\x00\x04\xf4\x0f\x0a\ -g\xee\x00\x00\x06\x00\x0f/\x19\xcf\x00\x00\x01\x83i\x00\ -\x00\x07\x97\x03\x00\x00\x00b\x00D\x00u\x00n\x00k\ -\x00l\x00e\x00r\x00 \x00M\x00o\x00d\x00u\ -\x00s\x00 \x00w\x00i\x00r\x00d\x00 \x00z\ -\x00w\x00i\x00s\x00c\x00h\x00e\x00n\x00 \ -\x00{\x00}\x00 \x00u\x00n\x00d\x00 \x00{\ -\x00}\x00 \x00a\x00k\x00t\x00i\x00v\x00 \ -\x00s\x00e\x00i\x00n\x00.\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00+Dark mode wi\ -ll be active bet\ -ween {} and {}.\x07\ -\x00\x00\x00\x0aMainWindow\x01\x03\ -\x00\x00\x00:\x00\xd6\x00f\x00f\x00n\x00e\x00 \ -\x00d\x00u\x00n\x00k\x00l\x00e\x00s\x00 \ -\x00H\x00i\x00n\x00t\x00e\x00r\x00g\x00r\ -\x00u\x00n\x00d\x00b\x00i\x00l\x00d\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x13Open dar\ -k wallpaper\x07\x00\x00\x00\x0a\ -MainWindow\x01\x03\x00\x00\x008\ -\x00\xd6\x00f\x00f\x00n\x00e\x00 \x00h\x00e\ -\x00l\x00l\x00e\x00s\x00 \x00H\x00i\x00n\ -\x00t\x00e\x00r\x00g\x00r\x00u\x00n\x00d\ -\x00b\x00i\x00l\x00d\x08\x00\x00\x00\x00\x06\x00\x00\ -\x00\x14Open light wal\ -lpaper\x07\x00\x00\x00\x0aMainW\ -indow\x01\x03\x00\x00\x00z\x00D\x00i\x00\ -e\x00 \x00E\x00i\x00n\x00s\x00t\x00e\x00\ -l\x00l\x00u\x00n\x00g\x00e\x00n\x00 \x00\ -w\x00u\x00r\x00d\x00e\x00n\x00 \x00g\x00\ -e\x00\xe4\x00n\x00d\x00e\x00r\x00t\x00.\x00\ - \x00M\x00\xf6\x00c\x00h\x00t\x00e\x00n\x00\ - \x00S\x00i\x00e\x00 \x00s\x00i\x00e\x00\ - \x00s\x00p\x00e\x00i\x00c\x00h\x00e\x00\ -r\x00n\x00?\x08\x00\x00\x00\x00\x06\x00\x00\x00:T\ -he settings have\ - been modified. \ -Do you want to s\ -ave them?\x07\x00\x00\x00\x0aMa\ -inWindow\x01\x03\x00\x00\x002\x00U\ -\x00n\x00g\x00e\x00s\x00p\x00e\x00i\x00c\ -\x00h\x00e\x00r\x00t\x00e\x00 \x00\xc4\x00n\ -\x00d\x00e\x00r\x00u\x00n\x00g\x00e\x00n\ -\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0fUnsave\ -d changes\x07\x00\x00\x00\x0aMa\ -inWindow\x01\x03\x00\x00\x000\x00S\ -\x00i\x00e\x00 \x00v\x00e\x00r\x00w\x00e\ -\x00n\x00d\x00e\x00n\x00 \x00V\x00e\x00r\ -\x00s\x00i\x00o\x00n\x00 \x00{\x00}\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x18You are \ -using version {}\ -\x07\x00\x00\x00\x0aMainWindow\x01\ -\x03\x00\x00\x006\x00A\x00u\x00t\x00o\x00m\x00\ -a\x00t\x00i\x00s\x00c\x00h\x00e\x00r\x00\ - \x00T\x00h\x00e\x00m\x00e\x00n\x00w\x00\ -e\x00c\x00h\x00s\x00e\x00l\x08\x00\x00\x00\x00\ -\x06\x00\x00\x00\x19Automatic t\ -heme switching\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x008\x00B\x00e\x00n\x00u\x00t\x00z\ -\x00e\x00r\x00d\x00e\x00f\x00i\x00n\x00i\ -\x00e\x00r\x00t\x00e\x00r\x00 \x00Z\x00e\ -\x00i\x00t\x00r\x00a\x00u\x00m\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00\x0fCustom Sch\ -edule\x07\x00\x00\x00\x0bmain_w\ -indow\x01\x03\x00\x00\x00\x0c\x00D\x00u\x00\ -n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x04Dark\x07\x00\x00\x00\x0bmain_w\ -indow\x01\x03\x00\x00\x00\x0e\x00D\x00u\x00\ -n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\ -\x00\x00\x05Dark:\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x18\x00B\ -\x00r\x00e\x00i\x00t\x00e\x00n\x00g\x00r\ -\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x09\ -Latitude:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x08\x00\ -H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x05Light\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00\x0a\x00H\x00e\ -\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x06\ -Light:\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00\x16\x00L\x00\xe4\ -\x00n\x00g\x00e\x00n\x00g\x00r\x00a\x00d\ -\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aLong\ -itude:\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00`\x00M\x00a\ -\x00c\x00h\x00e\x00 \x00e\x00i\x00n\x00 \ -\x00G\x00e\x00r\x00\xe4\x00u\x00s\x00c\x00h\ -\x00,\x00 \x00w\x00e\x00n\x00n\x00 \x00d\ -\x00a\x00s\x00 \x00T\x00h\x00e\x00m\x00a\ -\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00e\x00r\ -\x00t\x00 \x00w\x00i\x00r\x00d\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00%Make a sou\ -nd when switchin\ -g the theme\x07\x00\x00\x00\x0b\ -main_window\x01\x03\xff\xff\xff\ -\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Plugi\ -ns\x07\x00\x00\x00\x0bmain_wind\ -ow\x01\x03\x00\x00\x006\x00S\x00e\x00n\x00d\ -\x00e\x00 \x00e\x00i\x00n\x00e\x00 \x00B\ -\x00e\x00n\x00a\x00c\x00h\x00r\x00i\x00c\ -\x00h\x00t\x00i\x00g\x00u\x00n\x00g\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x13Send a n\ -otification\x07\x00\x00\x00\x0b\ +\x00\x00\x00\x05de_DEB\x00\x00\x00\x80\x00\x04\ +\xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x04\xc1\x00\x0a\ +KE\x00\x00\x02\x17\x00J\x88\xea\x00\x00\x01\x06\x00R\ +\xfd\xf4\x00\x00\x01z\x00\x89?\xc9\x00\x00\x04\x01\x03^\ +\x05u\x00\x00\x00o\x05/\xdfz\x00\x00\x01\xa7\x06\x99\ +\x04U\x00\x00\x03\x8e\x07;\xe0\x03\x00\x00\x02\xbc\x0ai\ +\xf3\xe7\x00\x00\x04z\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ +\xe8\x0a\x00\x00\x019\x0c\xbb\x01s\x00\x00\x03L\x0e\x0e\ +\x8c\xca\x00\x00\x01\xd7\x0f\x0ag\xee\x00\x00\x02\xe3i\x00\ +\x00\x04\xef\x03\x00\x00\x006\x00A\x00u\x00t\x00o\ +\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00e\ +\x00r\x00 \x00T\x00h\x00e\x00m\x00e\x00n\ +\x00w\x00e\x00c\x00h\x00s\x00e\x00l\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x19Automati\ +c theme switchin\ +g\x07\x00\x00\x00\x0bmain_windo\ +w\x01\x03\x00\x00\x008\x00B\x00e\x00n\x00u\x00\ +t\x00z\x00e\x00r\x00d\x00e\x00f\x00i\x00\ +n\x00i\x00e\x00r\x00t\x00e\x00r\x00 \x00\ +Z\x00e\x00i\x00t\x00r\x00a\x00u\x00m\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00\x0fCustom \ +Schedule\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\x0c\x00D\ +\x00u\x00n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x04Dark\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\x0e\x00D\ +\x00u\x00n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00\x05Dark:\x07\x00\x00\x00\x0b\ main_window\x01\x03\x00\x00\x00\ -\x1a\x00E\x00i\x00n\x00s\x00t\x00e\x00l\x00\ -l\x00u\x00n\x00g\x00e\x00n\x08\x00\x00\x00\x00\ -\x06\x00\x00\x00\x08Settings\x07\x00\x00\ -\x00\x0bmain_window\x01\x03\x00\ -\x00\x00B\x00S\x00o\x00n\x00n\x00e\x00n\x00\ -a\x00u\x00f\x00g\x00a\x00n\x00g\x00 \x00\ -b\x00i\x00s\x00 \x00S\x00o\x00n\x00n\x00\ -e\x00n\x00u\x00n\x00t\x00e\x00r\x00g\x00\ -a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11S\ -unset to Sunrise\ +\x18\x00B\x00r\x00e\x00i\x00t\x00e\x00n\x00\ +g\x00r\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\ +\x00\x00\x09Latitude:\x07\x00\x00\x00\ +\x0bmain_window\x01\x03\x00\x00\ +\x00\x08\x00H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x05Light\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x00\x0a\x00\ +H\x00e\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\ +\x00\x00\x06Light:\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x00\x16\x00\ +L\x00\xe4\x00n\x00g\x00e\x00n\x00g\x00r\x00\ +a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aL\ +ongitude:\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x00`\x00\ +M\x00a\x00c\x00h\x00e\x00 \x00e\x00i\x00\ +n\x00 \x00G\x00e\x00r\x00\xe4\x00u\x00s\x00\ +c\x00h\x00,\x00 \x00w\x00e\x00n\x00n\x00\ + \x00d\x00a\x00s\x00 \x00T\x00h\x00e\x00\ +m\x00a\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00\ +e\x00r\x00t\x00 \x00w\x00i\x00r\x00d\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00%Make a \ +sound when switc\ +hing the theme\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Pl\ +ugins\x07\x00\x00\x00\x0bmain_w\ +indow\x01\x03\x00\x00\x006\x00S\x00e\x00\ +n\x00d\x00e\x00 \x00e\x00i\x00n\x00e\x00\ + \x00B\x00e\x00n\x00a\x00c\x00h\x00r\x00\ +i\x00c\x00h\x00t\x00i\x00g\x00u\x00n\x00\ +g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13Send \ +a notification\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\x00\x00\x00\x1a\x00E\x00i\x00n\x00s\x00t\x00e\ +\x00l\x00l\x00u\x00n\x00g\x00e\x00n\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x08Settings\ \x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00<\x00P\x00o\x00s\x00i\x00t\ -\x00i\x00o\x00n\x00 \x00a\x00u\x00t\x00o\ -\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00 \ -\x00b\x00e\x00s\x00t\x00i\x00m\x00m\x00e\ -\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x1dupda\ -te location auto\ -matically\x07\x00\x00\x00\x0bma\ -in_window\x01\x88\x00\x00\x00\x02\x01\ -\x01\ +\x01\x03\x00\x00\x00B\x00S\x00o\x00n\x00n\x00e\ +\x00n\x00a\x00u\x00f\x00g\x00a\x00n\x00g\ +\x00 \x00b\x00i\x00s\x00 \x00S\x00o\x00n\ +\x00n\x00e\x00n\x00u\x00n\x00t\x00e\x00r\ +\x00g\x00a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\ +\x00\x11Sunset to Sunr\ +ise\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00<\x00P\x00o\x00s\x00\ +i\x00t\x00i\x00o\x00n\x00 \x00a\x00u\x00\ +t\x00o\x00m\x00a\x00t\x00i\x00s\x00c\x00\ +h\x00 \x00b\x00e\x00s\x00t\x00i\x00m\x00\ +m\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x1du\ +pdate location a\ +utomatically\x07\x00\x00\x00\ +\x0bmain_window\x01\x03\x00\x00\ +\x00\x1e\x00Y\x00i\x00n\x00 \x00Y\x00a\x00n\ +\x00g\x00 \x00\xf6\x00f\x00f\x00n\x00e\x00n\ +\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0dOpen Y\ +in Yang\x07\x00\x00\x00\x07syst\ +ray\x01\x03\x00\x00\x00\x0e\x00B\x00e\x00e\x00\ +n\x00d\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x04Quit\x07\x00\x00\x00\x07systra\ +y\x01\x88\x00\x00\x00\x02\x01\x01\ \x00\x00\x07\x22\ \x00\ \x00\x1dUx\xda\xcdYKs\xdb6\x10\xbe\xe7Wp\ @@ -289,8 +244,8 @@ \x00\x00\x00\x10\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00.\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x88\x15}\xd2\xab\ -\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x08f\ +\x00\x00\x01\x88\x1a\x87\xacR\ +\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x05\x9e\ \x00\x00\x01\x84\x01\xd5\x8cC\ " diff --git a/yin_yang/ui/main_window_connector.py b/yin_yang/ui/main_window_connector.py index e920edb6..a9ccfb26 100755 --- a/yin_yang/ui/main_window_connector.py +++ b/yin_yang/ui/main_window_connector.py @@ -2,7 +2,7 @@ from typing import cast from PySide6 import QtWidgets -from PySide6.QtCore import QStandardPaths, Slot +from PySide6.QtCore import QStandardPaths from PySide6.QtGui import QScreen, QColor from PySide6.QtWidgets import QFileDialog, QMessageBox, QDialogButtonBox, QColorDialog,QGroupBox From 89eec39fcf92229c72483e8930d0cd587119e109 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sun, 14 May 2023 16:40:00 +0200 Subject: [PATCH 18/35] Add setting for boot offset --- designer/main_window.ui | 28 +++- resources/translations/yin_yang.de_DE.qm | Bin 1434 -> 1825 bytes resources/translations/yin_yang.de_DE.ts | 21 ++- resources/translations/yin_yang.nl_NL.ts | 21 ++- yin_yang/config.py | 9 +- yin_yang/daemon_handler.py | 3 +- yin_yang/resources_rc.py | 186 ++++++++++++----------- yin_yang/ui/main_window.py | 30 +++- yin_yang/ui/main_window_connector.py | 7 + 9 files changed, 200 insertions(+), 105 deletions(-) diff --git a/designer/main_window.ui b/designer/main_window.ui index 237cea31..22e8ed8d 100755 --- a/designer/main_window.ui +++ b/designer/main_window.ui @@ -43,7 +43,7 @@ - 1 + 0 @@ -310,6 +310,30 @@ + + + + + + Time to wait until the system finished booting. Default value is 10 seconds. + + + Delay after boot: + + + + + + + s + + + 10 + + + + + @@ -351,7 +375,7 @@ 0 0 518 - 676 + 88 diff --git a/resources/translations/yin_yang.de_DE.qm b/resources/translations/yin_yang.de_DE.qm index b68e01df55168196a9175bd14bca2752bc5f831d..efcfecd868f1e8ed4d0b18d33b2e369e21ab8e8b 100644 GIT binary patch delta 516 zcmX|7!AcuZ6g`tnqRdF73n|^m?Osv?U9=W$7iksks@5)C1g6eQ^5|p+=DjgZHrci` z3qcTcWuS{@BNUhZfb|1(Sqp-qPzXwQh2D7yWtchVoqO&*@6MjvD{M`7wqSqz0^k(6 zt_|d$z*%_-WHgpPT?1AgZ~opfp5gQJA3*M7wvtQOALSnXY_reK@7ilX_Gawad6w~k zBX2L+H*og5i|m8zUOC*qu${ZV?O1?$) z``3AEX$J2g5TlJhs2P?ZWJdh;uz@4=)1)Rcr;2BhnP wR7+{mpsEa|ste!jE5llm%A)Eefu>C_NCZhmrCCyAVj~KDRZM@#cHbWS1E`C5^8f$< delta 155 zcmZ3;H;a3MTzvxr%ZhFW28L@4tUW9Y3@is3xV&8%7?{KvygFVnFfg()1pWO2q^lS@ z?N0*b8JXi)OM&Y1S@rK%0mYZI&14B>U|{ZJw|>A3)VGH#^Ye3{x+<;(J?=nt4BXr= yxPa;`d3G}v1J(KP@%5Yn@~`uArN3ifU}t)q2~_=l;}%=S&3;TLm?j&reFOj;#wJ_< diff --git a/resources/translations/yin_yang.de_DE.ts b/resources/translations/yin_yang.de_DE.ts index 9f4e7060..9c915de7 100644 --- a/resources/translations/yin_yang.de_DE.ts +++ b/resources/translations/yin_yang.de_DE.ts @@ -69,7 +69,22 @@ Sende eine Benachrichtigung - + + Time to wait until the system finished booting. Default value is 10 seconds. + Zeit die gewartet werden soll während das System startet. Standardwert ist 10 Sekunden. + + + + Delay after boot: + Verzögerung nach Start + + + + s + + + + Plugins @@ -77,13 +92,13 @@ systray - + Open Yin Yang Context menu action in the systray Yin Yang öffnen - + Quit Context menu action in the systray Beenden diff --git a/resources/translations/yin_yang.nl_NL.ts b/resources/translations/yin_yang.nl_NL.ts index 611c9cca..54f92da4 100644 --- a/resources/translations/yin_yang.nl_NL.ts +++ b/resources/translations/yin_yang.nl_NL.ts @@ -69,7 +69,22 @@ Melding tonen - + + Time to wait until the system finished booting. Default value is 10 seconds. + + + + + Delay after boot: + + + + + s + + + + Plugins Plug-ins @@ -77,13 +92,13 @@ systray - + Open Yin Yang Context menu action in the systray - + Quit Context menu action in the systray diff --git a/yin_yang/config.py b/yin_yang/config.py index 0d8fd1d3..eeaa9b38 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -351,6 +351,7 @@ def defaults(self) -> dict: 'update_location': False, 'update_interval': 60, 'times': ('07:00', '20:00'), + 'boot_offset': 10, 'plugins': {} } @@ -469,10 +470,14 @@ def desktop(self) -> Desktop: return get_desktop() @property - def update_interval(self) -> int: + def boot_offset(self) -> int: """Seconds that should pass until next check""" - return self['update_interval'] + return self['boot_offset'] + + @boot_offset.setter + def boot_offset(self, value: int): + self['boot_offset'] = value # create global object with current version diff --git a/yin_yang/daemon_handler.py b/yin_yang/daemon_handler.py index 5b7c92f7..6b845bf8 100644 --- a/yin_yang/daemon_handler.py +++ b/yin_yang/daemon_handler.py @@ -43,6 +43,7 @@ def update_times(): time_light, time_dark = config.times lines[4] = f'OnCalendar={time_light}\n' lines[5] = f'OnCalendar={time_dark}\n' + lines[6] = f'OnStartupSec={config.boot_offset}\n' with TIMER_PATH.open('w') as file: file.writelines(lines) @@ -73,7 +74,7 @@ def _set_needed_updates(self, change_values): self._next_timer_update = SaveWatcher._UpdateTimerStatus.STOP else: self._next_timer_update = SaveWatcher._UpdateTimerStatus.UPDATE_TIMES - case 'times' | 'coordinates': + case 'times' | 'coordinates' | 'boot_offset': self._next_timer_update = SaveWatcher._UpdateTimerStatus.UPDATE_TIMES def _update_timer(self): diff --git a/yin_yang/resources_rc.py b/yin_yang/resources_rc.py index 318ae0e8..86864119 100644 --- a/yin_yang/resources_rc.py +++ b/yin_yang/resources_rc.py @@ -6,98 +6,104 @@ from PySide6 import QtCore qt_resource_data = b"\ -\x00\x00\x05\x9a\ +\x00\x00\x05\xff\ <\ \xb8d\x18\xca\xef\x9c\x95\xcd!\x1c\xbf`\xa1\xbd\xdd\xa7\ -\x00\x00\x00\x05de_DEB\x00\x00\x00\x80\x00\x04\ -\xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x04\xc1\x00\x0a\ -KE\x00\x00\x02\x17\x00J\x88\xea\x00\x00\x01\x06\x00R\ -\xfd\xf4\x00\x00\x01z\x00\x89?\xc9\x00\x00\x04\x01\x03^\ -\x05u\x00\x00\x00o\x05/\xdfz\x00\x00\x01\xa7\x06\x99\ -\x04U\x00\x00\x03\x8e\x07;\xe0\x03\x00\x00\x02\xbc\x0ai\ -\xf3\xe7\x00\x00\x04z\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ -\xe8\x0a\x00\x00\x019\x0c\xbb\x01s\x00\x00\x03L\x0e\x0e\ -\x8c\xca\x00\x00\x01\xd7\x0f\x0ag\xee\x00\x00\x02\xe3i\x00\ -\x00\x04\xef\x03\x00\x00\x006\x00A\x00u\x00t\x00o\ -\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00e\ -\x00r\x00 \x00T\x00h\x00e\x00m\x00e\x00n\ -\x00w\x00e\x00c\x00h\x00s\x00e\x00l\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x19Automati\ -c theme switchin\ -g\x07\x00\x00\x00\x0bmain_windo\ -w\x01\x03\x00\x00\x008\x00B\x00e\x00n\x00u\x00\ -t\x00z\x00e\x00r\x00d\x00e\x00f\x00i\x00\ -n\x00i\x00e\x00r\x00t\x00e\x00r\x00 \x00\ -Z\x00e\x00i\x00t\x00r\x00a\x00u\x00m\x08\ -\x00\x00\x00\x00\x06\x00\x00\x00\x0fCustom \ -Schedule\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x0c\x00D\ -\x00u\x00n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00\x04Dark\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x0e\x00D\ -\x00u\x00n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00\x05Dark:\x07\x00\x00\x00\x0b\ -main_window\x01\x03\x00\x00\x00\ -\x18\x00B\x00r\x00e\x00i\x00t\x00e\x00n\x00\ -g\x00r\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\ -\x00\x00\x09Latitude:\x07\x00\x00\x00\ -\x0bmain_window\x01\x03\x00\x00\ -\x00\x08\x00H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00\x05Light\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x0a\x00\ -H\x00e\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\ -\x00\x00\x06Light:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x16\x00\ -L\x00\xe4\x00n\x00g\x00e\x00n\x00g\x00r\x00\ -a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aL\ -ongitude:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00`\x00\ -M\x00a\x00c\x00h\x00e\x00 \x00e\x00i\x00\ -n\x00 \x00G\x00e\x00r\x00\xe4\x00u\x00s\x00\ -c\x00h\x00,\x00 \x00w\x00e\x00n\x00n\x00\ - \x00d\x00a\x00s\x00 \x00T\x00h\x00e\x00\ -m\x00a\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00\ -e\x00r\x00t\x00 \x00w\x00i\x00r\x00d\x08\ -\x00\x00\x00\x00\x06\x00\x00\x00%Make a \ -sound when switc\ -hing the theme\x07\x00\ +\x00\x00\x00\x05de_DEB\x00\x00\x00\x88\x00\x04\ +\xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x05\x1e\x00\x0a\ +KE\x00\x00\x02t\x00J\x88\xea\x00\x00\x01\x06\x00R\ +\xfd\xf4\x00\x00\x01\xd7\x00\x89?\xc9\x00\x00\x04^\x03^\ +\x05u\x00\x00\x00o\x05/\xdfz\x00\x00\x02\x04\x06\x99\ +\x04U\x00\x00\x03\xeb\x07;\xe0\x03\x00\x00\x03\x19\x0ai\ +\xf3\xe7\x00\x00\x04\xd7\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ +\xe8\x0a\x00\x00\x01\x96\x0c\xbb\x01s\x00\x00\x03\xa9\x0e\x0e\ +\x8c\xca\x00\x00\x024\x0f\x0ag\xee\x00\x00\x03@\x0fF\ +^:\x00\x00\x019i\x00\x00\x05L\x03\x00\x00\x006\ +\x00A\x00u\x00t\x00o\x00m\x00a\x00t\x00i\ +\x00s\x00c\x00h\x00e\x00r\x00 \x00T\x00h\ +\x00e\x00m\x00e\x00n\x00w\x00e\x00c\x00h\ +\x00s\x00e\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x19\ +Automatic theme \ +switching\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x008\x00\ +B\x00e\x00n\x00u\x00t\x00z\x00e\x00r\x00\ +d\x00e\x00f\x00i\x00n\x00i\x00e\x00r\x00\ +t\x00e\x00r\x00 \x00Z\x00e\x00i\x00t\x00\ +r\x00a\x00u\x00m\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x0fCustom Schedule\ +\x07\x00\x00\x00\x0bmain_window\ +\x01\x03\x00\x00\x00\x0c\x00D\x00u\x00n\x00k\x00e\ +\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x04Dark\ +\x07\x00\x00\x00\x0bmain_window\ +\x01\x03\x00\x00\x00\x0e\x00D\x00u\x00n\x00k\x00e\ +\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x05Da\ +rk:\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00,\x00V\x00e\x00r\x00\ +z\x00\xf6\x00g\x00e\x00r\x00u\x00n\x00g\x00\ + \x00n\x00a\x00c\x00h\x00 \x00S\x00t\x00\ +a\x00r\x00t\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11D\ +elay after boot:\ +\x07\x00\x00\x00\x0bmain_window\ +\x01\x03\x00\x00\x00\x18\x00B\x00r\x00e\x00i\x00t\ +\x00e\x00n\x00g\x00r\x00a\x00d\x00:\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x09Latitude\ +:\x07\x00\x00\x00\x0bmain_windo\ +w\x01\x03\x00\x00\x00\x08\x00H\x00e\x00l\x00l\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00\x05Light\x07\x00\ \x00\x00\x0bmain_window\x01\x03\ -\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Pl\ -ugins\x07\x00\x00\x00\x0bmain_w\ -indow\x01\x03\x00\x00\x006\x00S\x00e\x00\ -n\x00d\x00e\x00 \x00e\x00i\x00n\x00e\x00\ - \x00B\x00e\x00n\x00a\x00c\x00h\x00r\x00\ -i\x00c\x00h\x00t\x00i\x00g\x00u\x00n\x00\ -g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13Send \ -a notification\x07\x00\ +\x00\x00\x00\x0a\x00H\x00e\x00l\x00l\x00:\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x06Light:\x07\x00\ \x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x00\x1a\x00E\x00i\x00n\x00s\x00t\x00e\ -\x00l\x00l\x00u\x00n\x00g\x00e\x00n\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x08Settings\ -\x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00B\x00S\x00o\x00n\x00n\x00e\ -\x00n\x00a\x00u\x00f\x00g\x00a\x00n\x00g\ -\x00 \x00b\x00i\x00s\x00 \x00S\x00o\x00n\ -\x00n\x00e\x00n\x00u\x00n\x00t\x00e\x00r\ -\x00g\x00a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\ -\x00\x11Sunset to Sunr\ -ise\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\x00\x00\x00<\x00P\x00o\x00s\x00\ -i\x00t\x00i\x00o\x00n\x00 \x00a\x00u\x00\ -t\x00o\x00m\x00a\x00t\x00i\x00s\x00c\x00\ -h\x00 \x00b\x00e\x00s\x00t\x00i\x00m\x00\ -m\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x1du\ -pdate location a\ -utomatically\x07\x00\x00\x00\ -\x0bmain_window\x01\x03\x00\x00\ -\x00\x1e\x00Y\x00i\x00n\x00 \x00Y\x00a\x00n\ -\x00g\x00 \x00\xf6\x00f\x00f\x00n\x00e\x00n\ -\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0dOpen Y\ -in Yang\x07\x00\x00\x00\x07syst\ -ray\x01\x03\x00\x00\x00\x0e\x00B\x00e\x00e\x00\ -n\x00d\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x04Quit\x07\x00\x00\x00\x07systra\ -y\x01\x88\x00\x00\x00\x02\x01\x01\ +\x00\x00\x00\x16\x00L\x00\xe4\x00n\x00g\x00e\x00n\ +\x00g\x00r\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x0aLongitude:\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\x00\x00\x00`\x00M\x00a\x00c\x00h\x00e\x00 \ +\x00e\x00i\x00n\x00 \x00G\x00e\x00r\x00\xe4\ +\x00u\x00s\x00c\x00h\x00,\x00 \x00w\x00e\ +\x00n\x00n\x00 \x00d\x00a\x00s\x00 \x00T\ +\x00h\x00e\x00m\x00a\x00 \x00g\x00e\x00\xe4\ +\x00n\x00d\x00e\x00r\x00t\x00 \x00w\x00i\ +\x00r\x00d\x08\x00\x00\x00\x00\x06\x00\x00\x00%Ma\ +ke a sound when \ +switching the th\ +eme\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\ +\x00\x00\x07Plugins\x07\x00\x00\x00\x0bm\ +ain_window\x01\x03\x00\x00\x006\ +\x00S\x00e\x00n\x00d\x00e\x00 \x00e\x00i\ +\x00n\x00e\x00 \x00B\x00e\x00n\x00a\x00c\ +\x00h\x00r\x00i\x00c\x00h\x00t\x00i\x00g\ +\x00u\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13\ +Send a notificat\ +ion\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00\x1a\x00E\x00i\x00n\x00\ +s\x00t\x00e\x00l\x00l\x00u\x00n\x00g\x00\ +e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x08Set\ +tings\x07\x00\x00\x00\x0bmain_w\ +indow\x01\x03\x00\x00\x00B\x00S\x00o\x00\ +n\x00n\x00e\x00n\x00a\x00u\x00f\x00g\x00\ +a\x00n\x00g\x00 \x00b\x00i\x00s\x00 \x00\ +S\x00o\x00n\x00n\x00e\x00n\x00u\x00n\x00\ +t\x00e\x00r\x00g\x00a\x00n\x00g\x08\x00\x00\ +\x00\x00\x06\x00\x00\x00\x11Sunset to\ + Sunrise\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00<\x00P\ +\x00o\x00s\x00i\x00t\x00i\x00o\x00n\x00 \ +\x00a\x00u\x00t\x00o\x00m\x00a\x00t\x00i\ +\x00s\x00c\x00h\x00 \x00b\x00e\x00s\x00t\ +\x00i\x00m\x00m\x00e\x00n\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x1dupdate locat\ +ion automaticall\ +y\x07\x00\x00\x00\x0bmain_windo\ +w\x01\x03\x00\x00\x00\x1e\x00Y\x00i\x00n\x00 \x00\ +Y\x00a\x00n\x00g\x00 \x00\xf6\x00f\x00f\x00\ +n\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0dO\ +pen Yin Yang\x07\x00\x00\x00\ +\x07systray\x01\x03\x00\x00\x00\x0e\x00B\ +\x00e\x00e\x00n\x00d\x00e\x00n\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00\x04Quit\x07\x00\x00\x00\x07s\ +ystray\x01\x88\x00\x00\x00\x02\x01\x01\ \x00\x00\x07\x22\ \x00\ \x00\x1dUx\xda\xcdYKs\xdb6\x10\xbe\xe7Wp\ @@ -244,8 +250,8 @@ \x00\x00\x00\x10\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00.\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x88\x1a\x87\xacR\ -\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x05\x9e\ +\x00\x00\x01\x88\x1a\xa8\xfe\xa0\ +\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x06\x03\ \x00\x00\x01\x84\x01\xd5\x8cC\ " diff --git a/yin_yang/ui/main_window.py b/yin_yang/ui/main_window.py index f62ae5d4..a7d2008e 100644 --- a/yin_yang/ui/main_window.py +++ b/yin_yang/ui/main_window.py @@ -19,8 +19,8 @@ QDialogButtonBox, QDoubleSpinBox, QFormLayout, QFrame, QGroupBox, QHBoxLayout, QLabel, QMainWindow, QPushButton, QRadioButton, QScrollArea, QSizePolicy, - QSpacerItem, QStatusBar, QTabWidget, QTimeEdit, - QVBoxLayout, QWidget) + QSpacerItem, QSpinBox, QStatusBar, QTabWidget, + QTimeEdit, QVBoxLayout, QWidget) import resources_rc class Ui_main_window(object): @@ -239,6 +239,23 @@ def setupUi(self, main_window): self.settings_layout.addWidget(self.toggle_notification) + self.bootOffsetSettings = QFormLayout() + self.bootOffsetSettings.setSpacing(6) + self.bootOffsetSettings.setObjectName(u"bootOffsetSettings") + self.bootOffsetLabel = QLabel(self.settings) + self.bootOffsetLabel.setObjectName(u"bootOffsetLabel") + + self.bootOffsetSettings.setWidget(0, QFormLayout.LabelRole, self.bootOffsetLabel) + + self.bootOffset = QSpinBox(self.settings) + self.bootOffset.setObjectName(u"bootOffset") + self.bootOffset.setValue(10) + + self.bootOffsetSettings.setWidget(0, QFormLayout.FieldRole, self.bootOffset) + + + self.settings_layout.addLayout(self.bootOffsetSettings) + self.label_active = QLabel(self.settings) self.label_active.setObjectName(u"label_active") self.label_active.setText(u"Darkmode will be active between") @@ -262,7 +279,7 @@ def setupUi(self, main_window): self.plugins_scroll.setWidgetResizable(True) self.plugins_scroll_content = QWidget() self.plugins_scroll_content.setObjectName(u"plugins_scroll_content") - self.plugins_scroll_content.setGeometry(QRect(0, 0, 518, 676)) + self.plugins_scroll_content.setGeometry(QRect(0, 0, 518, 88)) self.plugins_scroll_content_layout = QVBoxLayout(self.plugins_scroll_content) self.plugins_scroll_content_layout.setSpacing(6) self.plugins_scroll_content_layout.setContentsMargins(11, 11, 11, 11) @@ -324,7 +341,7 @@ def setupUi(self, main_window): self.btn_enable.toggled.connect(self.schedule_settings.setVisible) self.btn_enable.toggled.connect(self.manual_buttons.setHidden) - self.tab_widget.setCurrentIndex(1) + self.tab_widget.setCurrentIndex(0) QMetaObject.connectSlotsByName(main_window) @@ -343,6 +360,11 @@ def retranslateUi(self, main_window): self.button_dark.setText(QCoreApplication.translate("main_window", u"Dark", None)) self.toggle_sound.setText(QCoreApplication.translate("main_window", u"Make a sound when switching the theme", None)) self.toggle_notification.setText(QCoreApplication.translate("main_window", u"Send a notification", None)) +#if QT_CONFIG(tooltip) + self.bootOffsetLabel.setToolTip(QCoreApplication.translate("main_window", u"Time to wait until the system finished booting. Default value is 10 seconds.", None)) +#endif // QT_CONFIG(tooltip) + self.bootOffsetLabel.setText(QCoreApplication.translate("main_window", u"Delay after boot:", None)) + self.bootOffset.setSuffix(QCoreApplication.translate("main_window", u"s", None)) self.tab_widget.setTabText(self.tab_widget.indexOf(self.settings), QCoreApplication.translate("main_window", u"Settings", None)) self.tab_widget.setTabText(self.tab_widget.indexOf(self.plugins), QCoreApplication.translate("main_window", u"Plugins", None)) pass diff --git a/yin_yang/ui/main_window_connector.py b/yin_yang/ui/main_window_connector.py index a9ccfb26..ff7a45a3 100755 --- a/yin_yang/ui/main_window_connector.py +++ b/yin_yang/ui/main_window_connector.py @@ -83,6 +83,7 @@ def load(self): self.ui.toggle_sound.setChecked(config.get_plugin_key('sound', PluginKey.ENABLED)) self.ui.toggle_notification.setChecked(config.get_plugin_key('notification', PluginKey.ENABLED)) + self.ui.bootOffset.setValue(config.boot_offset) # sets the correct time based on config self.load_times() @@ -191,10 +192,16 @@ def setup_config_sync(self): self.ui.toggle_notification.toggled.connect( lambda enabled: config.update_plugin_key('notification', PluginKey.ENABLED, enabled)) + self.ui.bootOffset.valueChanged.connect(self.update_boot_offset) + # connect manual theme buttons self.ui.button_light.clicked.connect(lambda: set_mode(False)) self.ui.button_dark.clicked.connect(lambda: set_mode(True)) + @staticmethod + def update_boot_offset(value: int): + config.boot_offset = value + def save_mode(self): if not self.ui.btn_enable.isChecked(): config.mode = Modes.MANUAL From b3278a4430c1eb2cbf56ef4e98a7ac4d47e65830 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 15 May 2023 11:17:38 +0200 Subject: [PATCH 19/35] Fix taskbar icon on wayland --- yin_yang/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py index 2e9df8d4..e84f6e33 100755 --- a/yin_yang/__main__.py +++ b/yin_yang/__main__.py @@ -80,6 +80,8 @@ def systray_icon_clicked(reason: QSystemTrayIcon.ActivationReason): config.add_event_listener(ConfigEvent.SAVE, daemon_handler.watcher) config.add_event_listener(ConfigEvent.CHANGE, daemon_handler.watcher) app = QtWidgets.QApplication(sys.argv) + # fixes icon on wayland + app.setDesktopFileName('Yin-Yang') # load translation try: From 6dfb9ea9d5747480f3290e1677bbc6b0df20f930 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 15 May 2023 14:38:39 +0200 Subject: [PATCH 20/35] Move resources_rc --- resources/translations/yin_yang.de_DE.ts | 4 +- resources/translations/yin_yang.nl_NL.ts | 4 +- resources/yin-yang | 2 +- scripts/build_ui.sh | 4 +- yin_yang/ui/main_window.py | 2 +- yin_yang/{ => ui}/resources_rc.py | 207 +++++++++++++---------- 6 files changed, 121 insertions(+), 102 deletions(-) rename yin_yang/{ => ui}/resources_rc.py (60%) diff --git a/resources/translations/yin_yang.de_DE.ts b/resources/translations/yin_yang.de_DE.ts index 9c915de7..e61f07e4 100644 --- a/resources/translations/yin_yang.de_DE.ts +++ b/resources/translations/yin_yang.de_DE.ts @@ -92,13 +92,13 @@ systray - + Open Yin Yang Context menu action in the systray Yin Yang öffnen - + Quit Context menu action in the systray Beenden diff --git a/resources/translations/yin_yang.nl_NL.ts b/resources/translations/yin_yang.nl_NL.ts index 54f92da4..d5cd0bbc 100644 --- a/resources/translations/yin_yang.nl_NL.ts +++ b/resources/translations/yin_yang.nl_NL.ts @@ -92,13 +92,13 @@ systray - + Open Yin Yang Context menu action in the systray - + Quit Context menu action in the systray diff --git a/resources/yin-yang b/resources/yin-yang index adceaa15..c01d529d 100755 --- a/resources/yin-yang +++ b/resources/yin-yang @@ -1,3 +1,3 @@ #!/bin/bash cd /opt/yin-yang/ || exit -python3 -Om /opt/yin-yang/yin_yang "$@" +python3 -Om yin_yang "$@" diff --git a/scripts/build_ui.sh b/scripts/build_ui.sh index ef81ce89..c299d3ee 100755 --- a/scripts/build_ui.sh +++ b/scripts/build_ui.sh @@ -1,9 +1,9 @@ #!/bin/bash # resource file -pyside6-rcc ./resources/resources.qrc -o ./yin_yang/resources_rc.py +pyside6-rcc ./resources/resources.qrc -o ./yin_yang/ui/resources_rc.py # ui file from qt designer -pyside6-uic ./designer/main_window.ui > ./yin_yang/ui/main_window.py +pyside6-uic --from-imports ./designer/main_window.ui -o ./yin_yang/ui/main_window.py # extract strings to translate (doesn't work with .pro file unfortunately) pyside6-lupdate ./designer/main_window.ui ./yin_yang/* \ -ts resources/translations/yin_yang.*.ts -no-obsolete diff --git a/yin_yang/ui/main_window.py b/yin_yang/ui/main_window.py index a7d2008e..79c0e585 100644 --- a/yin_yang/ui/main_window.py +++ b/yin_yang/ui/main_window.py @@ -21,7 +21,7 @@ QPushButton, QRadioButton, QScrollArea, QSizePolicy, QSpacerItem, QSpinBox, QStatusBar, QTabWidget, QTimeEdit, QVBoxLayout, QWidget) -import resources_rc +from . import resources_rc class Ui_main_window(object): def setupUi(self, main_window): diff --git a/yin_yang/resources_rc.py b/yin_yang/ui/resources_rc.py similarity index 60% rename from yin_yang/resources_rc.py rename to yin_yang/ui/resources_rc.py index 86864119..eca95ad9 100644 --- a/yin_yang/resources_rc.py +++ b/yin_yang/ui/resources_rc.py @@ -6,104 +6,123 @@ from PySide6 import QtCore qt_resource_data = b"\ -\x00\x00\x05\xff\ +\x00\x00\x07!\ <\ \xb8d\x18\xca\xef\x9c\x95\xcd!\x1c\xbf`\xa1\xbd\xdd\xa7\ -\x00\x00\x00\x05de_DEB\x00\x00\x00\x88\x00\x04\ -\xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x05\x1e\x00\x0a\ +\x00\x00\x00\x05de_DEB\x00\x00\x00\x90\x00\x04\ +\xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x068\x00\x0a\ KE\x00\x00\x02t\x00J\x88\xea\x00\x00\x01\x06\x00R\ -\xfd\xf4\x00\x00\x01\xd7\x00\x89?\xc9\x00\x00\x04^\x03^\ +\xfd\xf4\x00\x00\x01\xd7\x00\x89?\xc9\x00\x00\x05x\x03^\ \x05u\x00\x00\x00o\x05/\xdfz\x00\x00\x02\x04\x06\x99\ \x04U\x00\x00\x03\xeb\x07;\xe0\x03\x00\x00\x03\x19\x0ai\ -\xf3\xe7\x00\x00\x04\xd7\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ -\xe8\x0a\x00\x00\x01\x96\x0c\xbb\x01s\x00\x00\x03\xa9\x0e\x0e\ -\x8c\xca\x00\x00\x024\x0f\x0ag\xee\x00\x00\x03@\x0fF\ -^:\x00\x00\x019i\x00\x00\x05L\x03\x00\x00\x006\ -\x00A\x00u\x00t\x00o\x00m\x00a\x00t\x00i\ -\x00s\x00c\x00h\x00e\x00r\x00 \x00T\x00h\ -\x00e\x00m\x00e\x00n\x00w\x00e\x00c\x00h\ -\x00s\x00e\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x19\ -Automatic theme \ -switching\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x008\x00\ -B\x00e\x00n\x00u\x00t\x00z\x00e\x00r\x00\ -d\x00e\x00f\x00i\x00n\x00i\x00e\x00r\x00\ -t\x00e\x00r\x00 \x00Z\x00e\x00i\x00t\x00\ -r\x00a\x00u\x00m\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x0fCustom Schedule\ +\xf3\xe7\x00\x00\x05\xf1\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ +\xe8\x0a\x00\x00\x01\x96\x0b\xa1\xae>\x00\x00\x04^\x0c\xbb\ +\x01s\x00\x00\x03\xa9\x0e\x0e\x8c\xca\x00\x00\x024\x0f\x0a\ +g\xee\x00\x00\x03@\x0fF^:\x00\x00\x019i\x00\ +\x00\x06f\x03\x00\x00\x006\x00A\x00u\x00t\x00o\ +\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00e\ +\x00r\x00 \x00T\x00h\x00e\x00m\x00e\x00n\ +\x00w\x00e\x00c\x00h\x00s\x00e\x00l\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x19Automati\ +c theme switchin\ +g\x07\x00\x00\x00\x0bmain_windo\ +w\x01\x03\x00\x00\x008\x00B\x00e\x00n\x00u\x00\ +t\x00z\x00e\x00r\x00d\x00e\x00f\x00i\x00\ +n\x00i\x00e\x00r\x00t\x00e\x00r\x00 \x00\ +Z\x00e\x00i\x00t\x00r\x00a\x00u\x00m\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00\x0fCustom \ +Schedule\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\x0c\x00D\ +\x00u\x00n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x04Dark\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\x0e\x00D\ +\x00u\x00n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00\x05Dark:\x07\x00\x00\x00\x0b\ +main_window\x01\x03\x00\x00\x00\ +,\x00V\x00e\x00r\x00z\x00\xf6\x00g\x00e\x00\ +r\x00u\x00n\x00g\x00 \x00n\x00a\x00c\x00\ +h\x00 \x00S\x00t\x00a\x00r\x00t\x08\x00\x00\ +\x00\x00\x06\x00\x00\x00\x11Delay aft\ +er boot:\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\x18\x00B\ +\x00r\x00e\x00i\x00t\x00e\x00n\x00g\x00r\ +\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x09\ +Latitude:\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x00\x08\x00\ +H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x05Light\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00\x0a\x00H\x00e\ +\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x06\ +Light:\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00\x16\x00L\x00\xe4\ +\x00n\x00g\x00e\x00n\x00g\x00r\x00a\x00d\ +\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aLong\ +itude:\x07\x00\x00\x00\x0bmain_\ +window\x01\x03\x00\x00\x00`\x00M\x00a\ +\x00c\x00h\x00e\x00 \x00e\x00i\x00n\x00 \ +\x00G\x00e\x00r\x00\xe4\x00u\x00s\x00c\x00h\ +\x00,\x00 \x00w\x00e\x00n\x00n\x00 \x00d\ +\x00a\x00s\x00 \x00T\x00h\x00e\x00m\x00a\ +\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00e\x00r\ +\x00t\x00 \x00w\x00i\x00r\x00d\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00%Make a sou\ +nd when switchin\ +g the theme\x07\x00\x00\x00\x0b\ +main_window\x01\x03\xff\xff\xff\ +\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Plugi\ +ns\x07\x00\x00\x00\x0bmain_wind\ +ow\x01\x03\x00\x00\x006\x00S\x00e\x00n\x00d\ +\x00e\x00 \x00e\x00i\x00n\x00e\x00 \x00B\ +\x00e\x00n\x00a\x00c\x00h\x00r\x00i\x00c\ +\x00h\x00t\x00i\x00g\x00u\x00n\x00g\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x13Send a n\ +otification\x07\x00\x00\x00\x0b\ +main_window\x01\x03\x00\x00\x00\ +\x1a\x00E\x00i\x00n\x00s\x00t\x00e\x00l\x00\ +l\x00u\x00n\x00g\x00e\x00n\x08\x00\x00\x00\x00\ +\x06\x00\x00\x00\x08Settings\x07\x00\x00\ +\x00\x0bmain_window\x01\x03\x00\ +\x00\x00B\x00S\x00o\x00n\x00n\x00e\x00n\x00\ +a\x00u\x00f\x00g\x00a\x00n\x00g\x00 \x00\ +b\x00i\x00s\x00 \x00S\x00o\x00n\x00n\x00\ +e\x00n\x00u\x00n\x00t\x00e\x00r\x00g\x00\ +a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11S\ +unset to Sunrise\ \x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00\x0c\x00D\x00u\x00n\x00k\x00e\ -\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x04Dark\ -\x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00\x0e\x00D\x00u\x00n\x00k\x00e\ -\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x05Da\ -rk:\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\x00\x00\x00,\x00V\x00e\x00r\x00\ -z\x00\xf6\x00g\x00e\x00r\x00u\x00n\x00g\x00\ - \x00n\x00a\x00c\x00h\x00 \x00S\x00t\x00\ -a\x00r\x00t\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11D\ -elay after boot:\ -\x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00\x18\x00B\x00r\x00e\x00i\x00t\ -\x00e\x00n\x00g\x00r\x00a\x00d\x00:\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x09Latitude\ -:\x07\x00\x00\x00\x0bmain_windo\ -w\x01\x03\x00\x00\x00\x08\x00H\x00e\x00l\x00l\x08\ -\x00\x00\x00\x00\x06\x00\x00\x00\x05Light\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x00\x0a\x00H\x00e\x00l\x00l\x00:\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x06Light:\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x00\x16\x00L\x00\xe4\x00n\x00g\x00e\x00n\ -\x00g\x00r\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00\x0aLongitude:\x07\x00\ -\x00\x00\x0bmain_window\x01\x03\ -\x00\x00\x00`\x00M\x00a\x00c\x00h\x00e\x00 \ -\x00e\x00i\x00n\x00 \x00G\x00e\x00r\x00\xe4\ -\x00u\x00s\x00c\x00h\x00,\x00 \x00w\x00e\ -\x00n\x00n\x00 \x00d\x00a\x00s\x00 \x00T\ -\x00h\x00e\x00m\x00a\x00 \x00g\x00e\x00\xe4\ -\x00n\x00d\x00e\x00r\x00t\x00 \x00w\x00i\ -\x00r\x00d\x08\x00\x00\x00\x00\x06\x00\x00\x00%Ma\ -ke a sound when \ -switching the th\ -eme\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\ -\x00\x00\x07Plugins\x07\x00\x00\x00\x0bm\ -ain_window\x01\x03\x00\x00\x006\ -\x00S\x00e\x00n\x00d\x00e\x00 \x00e\x00i\ -\x00n\x00e\x00 \x00B\x00e\x00n\x00a\x00c\ -\x00h\x00r\x00i\x00c\x00h\x00t\x00i\x00g\ -\x00u\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13\ -Send a notificat\ -ion\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\x00\x00\x00\x1a\x00E\x00i\x00n\x00\ -s\x00t\x00e\x00l\x00l\x00u\x00n\x00g\x00\ -e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x08Set\ -tings\x07\x00\x00\x00\x0bmain_w\ -indow\x01\x03\x00\x00\x00B\x00S\x00o\x00\ -n\x00n\x00e\x00n\x00a\x00u\x00f\x00g\x00\ -a\x00n\x00g\x00 \x00b\x00i\x00s\x00 \x00\ -S\x00o\x00n\x00n\x00e\x00n\x00u\x00n\x00\ -t\x00e\x00r\x00g\x00a\x00n\x00g\x08\x00\x00\ -\x00\x00\x06\x00\x00\x00\x11Sunset to\ - Sunrise\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00<\x00P\ -\x00o\x00s\x00i\x00t\x00i\x00o\x00n\x00 \ -\x00a\x00u\x00t\x00o\x00m\x00a\x00t\x00i\ -\x00s\x00c\x00h\x00 \x00b\x00e\x00s\x00t\ -\x00i\x00m\x00m\x00e\x00n\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00\x1dupdate locat\ -ion automaticall\ -y\x07\x00\x00\x00\x0bmain_windo\ -w\x01\x03\x00\x00\x00\x1e\x00Y\x00i\x00n\x00 \x00\ -Y\x00a\x00n\x00g\x00 \x00\xf6\x00f\x00f\x00\ -n\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0dO\ -pen Yin Yang\x07\x00\x00\x00\ -\x07systray\x01\x03\x00\x00\x00\x0e\x00B\ -\x00e\x00e\x00n\x00d\x00e\x00n\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00\x04Quit\x07\x00\x00\x00\x07s\ -ystray\x01\x88\x00\x00\x00\x02\x01\x01\ +\x01\x03\x00\x00\x00\xae\x00Z\x00e\x00i\x00t\x00 \ +\x00d\x00i\x00e\x00 \x00g\x00e\x00w\x00a\ +\x00r\x00t\x00e\x00t\x00 \x00w\x00e\x00r\ +\x00d\x00e\x00n\x00 \x00s\x00o\x00l\x00l\ +\x00 \x00w\x00\xe4\x00h\x00r\x00e\x00n\x00d\ +\x00 \x00d\x00a\x00s\x00 \x00S\x00y\x00s\ +\x00t\x00e\x00m\x00 \x00s\x00t\x00a\x00r\ +\x00t\x00e\x00t\x00.\x00 \x00S\x00t\x00a\ +\x00n\x00d\x00a\x00r\x00d\x00w\x00e\x00r\ +\x00t\x00 \x00i\x00s\x00t\x00 \x001\x000\ +\x00 \x00S\x00e\x00k\x00u\x00n\x00d\x00e\ +\x00n\x00.\x08\x00\x00\x00\x00\x06\x00\x00\x00LTi\ +me to wait until\ + the system fini\ +shed booting. De\ +fault value is 1\ +0 seconds.\x07\x00\x00\x00\x0bm\ +ain_window\x01\x03\x00\x00\x00<\ +\x00P\x00o\x00s\x00i\x00t\x00i\x00o\x00n\ +\x00 \x00a\x00u\x00t\x00o\x00m\x00a\x00t\ +\x00i\x00s\x00c\x00h\x00 \x00b\x00e\x00s\ +\x00t\x00i\x00m\x00m\x00e\x00n\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00\x1dupdate loc\ +ation automatica\ +lly\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00\x1e\x00Y\x00i\x00n\x00\ + \x00Y\x00a\x00n\x00g\x00 \x00\xf6\x00f\x00\ +f\x00n\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x0dOpen Yin Yang\x07\x00\ +\x00\x00\x07systray\x01\x03\x00\x00\x00\x0e\ +\x00B\x00e\x00e\x00n\x00d\x00e\x00n\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x04Quit\x07\x00\x00\x00\ +\x07systray\x01\x88\x00\x00\x00\x02\x01\x01\ +\ \x00\x00\x07\x22\ \x00\ \x00\x1dUx\xda\xcdYKs\xdb6\x10\xbe\xe7Wp\ @@ -250,8 +269,8 @@ \x00\x00\x00\x10\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00.\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x88\x1a\xa8\xfe\xa0\ -\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x06\x03\ +\x00\x00\x01\x88\x1fj:\x04\ +\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x07%\ \x00\x00\x01\x84\x01\xd5\x8cC\ " From 7bbeb7ed9542777be62237bded0018926599c73d Mon Sep 17 00:00:00 2001 From: l0drex Date: Wed, 17 May 2023 12:10:19 +0200 Subject: [PATCH 21/35] Use old positioning method via ipinfo.io as a fallback --- yin_yang/config.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/yin_yang/config.py b/yin_yang/config.py index eeaa9b38..c3fce903 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -8,6 +8,7 @@ from time import sleep from typing import Union, Optional +import requests from PySide6.QtCore import QObject from PySide6.QtPositioning import QGeoPositionInfoSource, QGeoPositionInfo, QGeoCoordinate from psutil import process_iter, NoSuchProcess @@ -119,6 +120,7 @@ def get_sun_time(latitude, longitude) -> tuple[time, time]: locationSource = QGeoPositionInfoSource.createDefaultSource(parent) +@cache def get_current_location() -> QGeoCoordinate: if locationSource is None: logger.error("No location source is available") @@ -134,8 +136,13 @@ def get_current_location() -> QGeoCoordinate: sleep(1) coordinate = pos.coordinate() if not coordinate.isValid(): - logger.error('Location could not be determined') - return QGeoCoordinate(0, 0) + logger.warning('Location could not be determined. Using ipinfo.io to get location') + # use the old method as a fallback + loc_response = requests.get('https://www.ipinfo.io/loc').text.split(',') + loc: [float] = [float(coordinate) for coordinate in loc_response] + assert len(loc) == 2, 'The returned location should have exactly 2 values.' + coordinate = QGeoCoordinate(loc[0], loc[1]) + assert coordinate.isValid() return coordinate From 3dd25add05c58275754790cc0545d19a644a9ee7 Mon Sep 17 00:00:00 2001 From: l0drex Date: Wed, 17 May 2023 12:13:01 +0200 Subject: [PATCH 22/35] Update requirements --- requirements.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index bb20c0c4..98ba4ba7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,6 @@ -numpy==1.24.2 psutil==5.9.5 PySide6==6.5.0 PySide6-Addons==6.5.0 -PySide6-Essentials==6.5.0 -python-dateutil==2.8.2 -shiboken6==6.5.0 -six==1.16.0 suntime==1.2.5 systemd-python==235 +requests~=2.28.2 \ No newline at end of file From ac689e4d9e7441e8446b1c9f49bb2228ae10b508 Mon Sep 17 00:00:00 2001 From: l0drex Date: Wed, 17 May 2023 12:26:39 +0200 Subject: [PATCH 23/35] Add toggle theme action to systray icon --- resources/translations/yin_yang.de_DE.qm | Bin 1825 -> 1911 bytes resources/translations/yin_yang.de_DE.ts | 10 +- resources/translations/yin_yang.nl_NL.ts | 10 +- yin_yang/__main__.py | 1 + yin_yang/ui/resources_rc.py | 233 ++++++++++++----------- 5 files changed, 136 insertions(+), 118 deletions(-) diff --git a/resources/translations/yin_yang.de_DE.qm b/resources/translations/yin_yang.de_DE.qm index efcfecd868f1e8ed4d0b18d33b2e369e21ab8e8b..dfe9e222b2fe83a072195c8717fcf9b7d7c027a0 100644 GIT binary patch delta 115 zcmZ3;_nmKo9OI0M@&+7C=gmYJ7}(M#`lm2%*|;T*EtHvofkBPIjUkbth#`rgm?4=V zgCUh67syv&CFGJC3MCn-xvA_x0ruj`;*z4oO2!T# Ihl!C905YE$f&c&j delta 28 kcmey)w~%jw9OHzE@&*&bQy9}W?nz@~?_gkHU}9th0FECA^8f$< diff --git a/resources/translations/yin_yang.de_DE.ts b/resources/translations/yin_yang.de_DE.ts index e61f07e4..1a0a1935 100644 --- a/resources/translations/yin_yang.de_DE.ts +++ b/resources/translations/yin_yang.de_DE.ts @@ -92,13 +92,19 @@ systray - + Open Yin Yang Context menu action in the systray Yin Yang öffnen - + + Toggle theme + Context menu action in the systray + Farbschema wechseln + + + Quit Context menu action in the systray Beenden diff --git a/resources/translations/yin_yang.nl_NL.ts b/resources/translations/yin_yang.nl_NL.ts index d5cd0bbc..067aec4d 100644 --- a/resources/translations/yin_yang.nl_NL.ts +++ b/resources/translations/yin_yang.nl_NL.ts @@ -92,13 +92,19 @@ systray - + Open Yin Yang Context menu action in the systray - + + Toggle theme + Context menu action in the systray + + + + Quit Context menu action in the systray diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py index e84f6e33..2ef272a4 100755 --- a/yin_yang/__main__.py +++ b/yin_yang/__main__.py @@ -118,6 +118,7 @@ def systray_icon_clicked(reason: QSystemTrayIcon.ActivationReason): menu = QMenu('Yin & Yang') menu.addAction(app.translate('systray', 'Open Yin Yang', 'Context menu action in the systray'), lambda: window.show()) + menu.addAction(app.translate('systray', 'Toggle theme', 'Context menu action in the systray'), lambda: theme_switcher.set_mode(not config.dark_mode)) menu.addAction(QIcon.fromTheme('application-exit'), app.translate('systray', 'Quit', 'Context menu action in the systray'), app.quit) icon.setContextMenu(menu) diff --git a/yin_yang/ui/resources_rc.py b/yin_yang/ui/resources_rc.py index eca95ad9..28b759c1 100644 --- a/yin_yang/ui/resources_rc.py +++ b/yin_yang/ui/resources_rc.py @@ -6,123 +6,128 @@ from PySide6 import QtCore qt_resource_data = b"\ -\x00\x00\x07!\ +\x00\x00\x07w\ <\ \xb8d\x18\xca\xef\x9c\x95\xcd!\x1c\xbf`\xa1\xbd\xdd\xa7\ -\x00\x00\x00\x05de_DEB\x00\x00\x00\x90\x00\x04\ +\x00\x00\x00\x05de_DEB\x00\x00\x00\x98\x00\x04\ \xa8\x8b\x00\x00\x00\xd6\x00\x05\x8c\x04\x00\x00\x068\x00\x0a\ KE\x00\x00\x02t\x00J\x88\xea\x00\x00\x01\x06\x00R\ -\xfd\xf4\x00\x00\x01\xd7\x00\x89?\xc9\x00\x00\x05x\x03^\ -\x05u\x00\x00\x00o\x05/\xdfz\x00\x00\x02\x04\x06\x99\ -\x04U\x00\x00\x03\xeb\x07;\xe0\x03\x00\x00\x03\x19\x0ai\ -\xf3\xe7\x00\x00\x05\xf1\x0a\xa0\x8cG\x00\x00\x00\x00\x0b\x0b\ -\xe8\x0a\x00\x00\x01\x96\x0b\xa1\xae>\x00\x00\x04^\x0c\xbb\ -\x01s\x00\x00\x03\xa9\x0e\x0e\x8c\xca\x00\x00\x024\x0f\x0a\ -g\xee\x00\x00\x03@\x0fF^:\x00\x00\x019i\x00\ -\x00\x06f\x03\x00\x00\x006\x00A\x00u\x00t\x00o\ -\x00m\x00a\x00t\x00i\x00s\x00c\x00h\x00e\ -\x00r\x00 \x00T\x00h\x00e\x00m\x00e\x00n\ -\x00w\x00e\x00c\x00h\x00s\x00e\x00l\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x19Automati\ -c theme switchin\ -g\x07\x00\x00\x00\x0bmain_windo\ -w\x01\x03\x00\x00\x008\x00B\x00e\x00n\x00u\x00\ -t\x00z\x00e\x00r\x00d\x00e\x00f\x00i\x00\ -n\x00i\x00e\x00r\x00t\x00e\x00r\x00 \x00\ -Z\x00e\x00i\x00t\x00r\x00a\x00u\x00m\x08\ -\x00\x00\x00\x00\x06\x00\x00\x00\x0fCustom \ -Schedule\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x0c\x00D\ -\x00u\x00n\x00k\x00e\x00l\x08\x00\x00\x00\x00\x06\ -\x00\x00\x00\x04Dark\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x0e\x00D\ -\x00u\x00n\x00k\x00e\x00l\x00:\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00\x05Dark:\x07\x00\x00\x00\x0b\ -main_window\x01\x03\x00\x00\x00\ -,\x00V\x00e\x00r\x00z\x00\xf6\x00g\x00e\x00\ -r\x00u\x00n\x00g\x00 \x00n\x00a\x00c\x00\ -h\x00 \x00S\x00t\x00a\x00r\x00t\x08\x00\x00\ -\x00\x00\x06\x00\x00\x00\x11Delay aft\ -er boot:\x07\x00\x00\x00\x0bmai\ -n_window\x01\x03\x00\x00\x00\x18\x00B\ -\x00r\x00e\x00i\x00t\x00e\x00n\x00g\x00r\ -\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x09\ -Latitude:\x07\x00\x00\x00\x0bma\ -in_window\x01\x03\x00\x00\x00\x08\x00\ -H\x00e\x00l\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x05Light\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00\x0a\x00H\x00e\ -\x00l\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x06\ -Light:\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00\x16\x00L\x00\xe4\ -\x00n\x00g\x00e\x00n\x00g\x00r\x00a\x00d\ -\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x0aLong\ -itude:\x07\x00\x00\x00\x0bmain_\ -window\x01\x03\x00\x00\x00`\x00M\x00a\ -\x00c\x00h\x00e\x00 \x00e\x00i\x00n\x00 \ -\x00G\x00e\x00r\x00\xe4\x00u\x00s\x00c\x00h\ -\x00,\x00 \x00w\x00e\x00n\x00n\x00 \x00d\ -\x00a\x00s\x00 \x00T\x00h\x00e\x00m\x00a\ -\x00 \x00g\x00e\x00\xe4\x00n\x00d\x00e\x00r\ -\x00t\x00 \x00w\x00i\x00r\x00d\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00%Make a sou\ -nd when switchin\ -g the theme\x07\x00\x00\x00\x0b\ -main_window\x01\x03\xff\xff\xff\ -\xff\x08\x00\x00\x00\x00\x06\x00\x00\x00\x07Plugi\ -ns\x07\x00\x00\x00\x0bmain_wind\ -ow\x01\x03\x00\x00\x006\x00S\x00e\x00n\x00d\ -\x00e\x00 \x00e\x00i\x00n\x00e\x00 \x00B\ -\x00e\x00n\x00a\x00c\x00h\x00r\x00i\x00c\ -\x00h\x00t\x00i\x00g\x00u\x00n\x00g\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x13Send a n\ -otification\x07\x00\x00\x00\x0b\ -main_window\x01\x03\x00\x00\x00\ -\x1a\x00E\x00i\x00n\x00s\x00t\x00e\x00l\x00\ -l\x00u\x00n\x00g\x00e\x00n\x08\x00\x00\x00\x00\ -\x06\x00\x00\x00\x08Settings\x07\x00\x00\ -\x00\x0bmain_window\x01\x03\x00\ -\x00\x00B\x00S\x00o\x00n\x00n\x00e\x00n\x00\ -a\x00u\x00f\x00g\x00a\x00n\x00g\x00 \x00\ -b\x00i\x00s\x00 \x00S\x00o\x00n\x00n\x00\ -e\x00n\x00u\x00n\x00t\x00e\x00r\x00g\x00\ -a\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11S\ -unset to Sunrise\ +\xfd\xf4\x00\x00\x01\xd7\x00\x89?\xc9\x00\x00\x05x\x02\xcf\ +6\x15\x00\x00\x06f\x03^\x05u\x00\x00\x00o\x05/\ +\xdfz\x00\x00\x02\x04\x06\x99\x04U\x00\x00\x03\xeb\x07;\ +\xe0\x03\x00\x00\x03\x19\x0ai\xf3\xe7\x00\x00\x05\xf1\x0a\xa0\ +\x8cG\x00\x00\x00\x00\x0b\x0b\xe8\x0a\x00\x00\x01\x96\x0b\xa1\ +\xae>\x00\x00\x04^\x0c\xbb\x01s\x00\x00\x03\xa9\x0e\x0e\ +\x8c\xca\x00\x00\x024\x0f\x0ag\xee\x00\x00\x03@\x0fF\ +^:\x00\x00\x019i\x00\x00\x06\xb4\x03\x00\x00\x006\ +\x00A\x00u\x00t\x00o\x00m\x00a\x00t\x00i\ +\x00s\x00c\x00h\x00e\x00r\x00 \x00T\x00h\ +\x00e\x00m\x00e\x00n\x00w\x00e\x00c\x00h\ +\x00s\x00e\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x19\ +Automatic theme \ +switching\x07\x00\x00\x00\x0bma\ +in_window\x01\x03\x00\x00\x008\x00\ +B\x00e\x00n\x00u\x00t\x00z\x00e\x00r\x00\ +d\x00e\x00f\x00i\x00n\x00i\x00e\x00r\x00\ +t\x00e\x00r\x00 \x00Z\x00e\x00i\x00t\x00\ +r\x00a\x00u\x00m\x08\x00\x00\x00\x00\x06\x00\x00\x00\ +\x0fCustom Schedule\ +\x07\x00\x00\x00\x0bmain_window\ +\x01\x03\x00\x00\x00\x0c\x00D\x00u\x00n\x00k\x00e\ +\x00l\x08\x00\x00\x00\x00\x06\x00\x00\x00\x04Dark\ \x07\x00\x00\x00\x0bmain_window\ -\x01\x03\x00\x00\x00\xae\x00Z\x00e\x00i\x00t\x00 \ -\x00d\x00i\x00e\x00 \x00g\x00e\x00w\x00a\ -\x00r\x00t\x00e\x00t\x00 \x00w\x00e\x00r\ -\x00d\x00e\x00n\x00 \x00s\x00o\x00l\x00l\ -\x00 \x00w\x00\xe4\x00h\x00r\x00e\x00n\x00d\ -\x00 \x00d\x00a\x00s\x00 \x00S\x00y\x00s\ -\x00t\x00e\x00m\x00 \x00s\x00t\x00a\x00r\ -\x00t\x00e\x00t\x00.\x00 \x00S\x00t\x00a\ -\x00n\x00d\x00a\x00r\x00d\x00w\x00e\x00r\ -\x00t\x00 \x00i\x00s\x00t\x00 \x001\x000\ -\x00 \x00S\x00e\x00k\x00u\x00n\x00d\x00e\ -\x00n\x00.\x08\x00\x00\x00\x00\x06\x00\x00\x00LTi\ -me to wait until\ - the system fini\ -shed booting. De\ -fault value is 1\ -0 seconds.\x07\x00\x00\x00\x0bm\ -ain_window\x01\x03\x00\x00\x00<\ -\x00P\x00o\x00s\x00i\x00t\x00i\x00o\x00n\ -\x00 \x00a\x00u\x00t\x00o\x00m\x00a\x00t\ -\x00i\x00s\x00c\x00h\x00 \x00b\x00e\x00s\ -\x00t\x00i\x00m\x00m\x00e\x00n\x08\x00\x00\x00\ -\x00\x06\x00\x00\x00\x1dupdate loc\ -ation automatica\ -lly\x07\x00\x00\x00\x0bmain_win\ -dow\x01\x03\x00\x00\x00\x1e\x00Y\x00i\x00n\x00\ - \x00Y\x00a\x00n\x00g\x00 \x00\xf6\x00f\x00\ -f\x00n\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\ -\x0dOpen Yin Yang\x07\x00\ -\x00\x00\x07systray\x01\x03\x00\x00\x00\x0e\ -\x00B\x00e\x00e\x00n\x00d\x00e\x00n\x08\x00\ -\x00\x00\x00\x06\x00\x00\x00\x04Quit\x07\x00\x00\x00\ -\x07systray\x01\x88\x00\x00\x00\x02\x01\x01\ -\ +\x01\x03\x00\x00\x00\x0e\x00D\x00u\x00n\x00k\x00e\ +\x00l\x00:\x08\x00\x00\x00\x00\x06\x00\x00\x00\x05Da\ +rk:\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00,\x00V\x00e\x00r\x00\ +z\x00\xf6\x00g\x00e\x00r\x00u\x00n\x00g\x00\ + \x00n\x00a\x00c\x00h\x00 \x00S\x00t\x00\ +a\x00r\x00t\x08\x00\x00\x00\x00\x06\x00\x00\x00\x11D\ +elay after boot:\ +\x07\x00\x00\x00\x0bmain_window\ +\x01\x03\x00\x00\x00\x18\x00B\x00r\x00e\x00i\x00t\ +\x00e\x00n\x00g\x00r\x00a\x00d\x00:\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x09Latitude\ +:\x07\x00\x00\x00\x0bmain_windo\ +w\x01\x03\x00\x00\x00\x08\x00H\x00e\x00l\x00l\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00\x05Light\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\x00\x00\x00\x0a\x00H\x00e\x00l\x00l\x00:\x08\x00\ +\x00\x00\x00\x06\x00\x00\x00\x06Light:\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\x00\x00\x00\x16\x00L\x00\xe4\x00n\x00g\x00e\x00n\ +\x00g\x00r\x00a\x00d\x00:\x08\x00\x00\x00\x00\x06\ +\x00\x00\x00\x0aLongitude:\x07\x00\ +\x00\x00\x0bmain_window\x01\x03\ +\x00\x00\x00`\x00M\x00a\x00c\x00h\x00e\x00 \ +\x00e\x00i\x00n\x00 \x00G\x00e\x00r\x00\xe4\ +\x00u\x00s\x00c\x00h\x00,\x00 \x00w\x00e\ +\x00n\x00n\x00 \x00d\x00a\x00s\x00 \x00T\ +\x00h\x00e\x00m\x00a\x00 \x00g\x00e\x00\xe4\ +\x00n\x00d\x00e\x00r\x00t\x00 \x00w\x00i\ +\x00r\x00d\x08\x00\x00\x00\x00\x06\x00\x00\x00%Ma\ +ke a sound when \ +switching the th\ +eme\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\xff\xff\xff\xff\x08\x00\x00\x00\x00\x06\x00\ +\x00\x00\x07Plugins\x07\x00\x00\x00\x0bm\ +ain_window\x01\x03\x00\x00\x006\ +\x00S\x00e\x00n\x00d\x00e\x00 \x00e\x00i\ +\x00n\x00e\x00 \x00B\x00e\x00n\x00a\x00c\ +\x00h\x00r\x00i\x00c\x00h\x00t\x00i\x00g\ +\x00u\x00n\x00g\x08\x00\x00\x00\x00\x06\x00\x00\x00\x13\ +Send a notificat\ +ion\x07\x00\x00\x00\x0bmain_win\ +dow\x01\x03\x00\x00\x00\x1a\x00E\x00i\x00n\x00\ +s\x00t\x00e\x00l\x00l\x00u\x00n\x00g\x00\ +e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x08Set\ +tings\x07\x00\x00\x00\x0bmain_w\ +indow\x01\x03\x00\x00\x00B\x00S\x00o\x00\ +n\x00n\x00e\x00n\x00a\x00u\x00f\x00g\x00\ +a\x00n\x00g\x00 \x00b\x00i\x00s\x00 \x00\ +S\x00o\x00n\x00n\x00e\x00n\x00u\x00n\x00\ +t\x00e\x00r\x00g\x00a\x00n\x00g\x08\x00\x00\ +\x00\x00\x06\x00\x00\x00\x11Sunset to\ + Sunrise\x07\x00\x00\x00\x0bmai\ +n_window\x01\x03\x00\x00\x00\xae\x00Z\ +\x00e\x00i\x00t\x00 \x00d\x00i\x00e\x00 \ +\x00g\x00e\x00w\x00a\x00r\x00t\x00e\x00t\ +\x00 \x00w\x00e\x00r\x00d\x00e\x00n\x00 \ +\x00s\x00o\x00l\x00l\x00 \x00w\x00\xe4\x00h\ +\x00r\x00e\x00n\x00d\x00 \x00d\x00a\x00s\ +\x00 \x00S\x00y\x00s\x00t\x00e\x00m\x00 \ +\x00s\x00t\x00a\x00r\x00t\x00e\x00t\x00.\ +\x00 \x00S\x00t\x00a\x00n\x00d\x00a\x00r\ +\x00d\x00w\x00e\x00r\x00t\x00 \x00i\x00s\ +\x00t\x00 \x001\x000\x00 \x00S\x00e\x00k\ +\x00u\x00n\x00d\x00e\x00n\x00.\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00LTime to wa\ +it until the sys\ +tem finished boo\ +ting. Default va\ +lue is 10 second\ +s.\x07\x00\x00\x00\x0bmain_wind\ +ow\x01\x03\x00\x00\x00<\x00P\x00o\x00s\x00i\ +\x00t\x00i\x00o\x00n\x00 \x00a\x00u\x00t\ +\x00o\x00m\x00a\x00t\x00i\x00s\x00c\x00h\ +\x00 \x00b\x00e\x00s\x00t\x00i\x00m\x00m\ +\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x1dup\ +date location au\ +tomatically\x07\x00\x00\x00\x0b\ +main_window\x01\x03\x00\x00\x00\ +\x1e\x00Y\x00i\x00n\x00 \x00Y\x00a\x00n\x00\ +g\x00 \x00\xf6\x00f\x00f\x00n\x00e\x00n\x08\ +\x00\x00\x00\x00\x06\x00\x00\x00\x0dOpen Yi\ +n Yang\x07\x00\x00\x00\x07systr\ +ay\x01\x03\x00\x00\x00\x0e\x00B\x00e\x00e\x00n\ +\x00d\x00e\x00n\x08\x00\x00\x00\x00\x06\x00\x00\x00\x04\ +Quit\x07\x00\x00\x00\x07systray\ +\x01\x03\x00\x00\x00&\x00F\x00a\x00r\x00b\x00s\ +\x00c\x00h\x00e\x00m\x00a\x00 \x00w\x00e\ +\x00c\x00h\x00s\x00e\x00l\x00n\x08\x00\x00\x00\ +\x00\x06\x00\x00\x00\x0cToggle the\ +me\x07\x00\x00\x00\x07systray\x01\x88\ +\x00\x00\x00\x02\x01\x01\ \x00\x00\x07\x22\ \x00\ \x00\x1dUx\xda\xcdYKs\xdb6\x10\xbe\xe7Wp\ @@ -269,8 +274,8 @@ \x00\x00\x00\x10\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00.\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x88\x1fj:\x04\ -\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x07%\ +\x00\x00\x01\x88)>\x08Z\ +\x00\x00\x00P\x00\x01\x00\x00\x00\x01\x00\x00\x07{\ \x00\x00\x01\x84\x01\xd5\x8cC\ " From 42ba120845524beff83cbf27fcdbb853a970dee6 Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 14 Jul 2023 13:55:06 +0200 Subject: [PATCH 24/35] Update installation instructions Closes #203 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 815b838c..7893ffcb 100755 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Yin-Yang can be downloaded from AUR as [yin-yang](https://aur.archlinux.org/pack ### Source -Yin-Yang depends on `python-systemd` and `pyside6` from pypi. `python-systemd` requires you have installed the systemd-headers from your package manager. +Yin-Yang depends on `python-systemd` and `pyside6` from pypi. `python-systemd` requires you have installed the systemd-headers from your package manager. You also need python development headers (e.g. `python3-devel`). For CentOS, RHEL, and Fedora: ```bash From b94819580241f7176b6cada1876620d8a1f912dd Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 14 Jul 2023 14:43:36 +0200 Subject: [PATCH 25/35] Fix issues with konsole plugin Close #200 --- yin_yang/plugins/konsole.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/yin_yang/plugins/konsole.py b/yin_yang/plugins/konsole.py index 055d52cf..f5119c07 100644 --- a/yin_yang/plugins/konsole.py +++ b/yin_yang/plugins/konsole.py @@ -130,6 +130,8 @@ def default_profile(self): # If a match is found, return the content of the wildcard '*' if match: value = match.group(1) + if not os.path.isfile(self.user_path / value): + value = None if value is None: # use the first found profile @@ -139,8 +141,9 @@ def default_profile(self): break if value is not None: logger.warning(f'No default profile found, using {value} instead.') - else: - raise ValueError('No Konsole profile found.') + + if value is None: + raise ValueError('No Konsole profile found.') return value @@ -176,11 +179,20 @@ def update_profile(self, dark: bool, theme: str): profile_config = ConfigParser() profile_config.optionxform = str profile_config.read(file_path) - profile_config['Appearance']['ColorScheme'] = theme + + try: + profile_config['Appearance']['ColorScheme'] = theme + except KeyError: + profile_config.add_section('Appearance') + profile_config['Appearance']['ColorScheme'] = theme + with open(file_path, 'w') as file: profile_config.write(file) def create_profiles(self): + if not self.default_profile: + raise ValueError('No default profile found.') + logger.debug('Creating new profiles for live-switching between light and dark themes.') # copy default profile to create theme profiles light_profile = self.user_path / 'Light.profile' From 30a63bad3fa135192c06e1c6e94bdb03be062d6a Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 14 Jul 2023 14:53:11 +0200 Subject: [PATCH 26/35] Create a default profile if none exists #200 --- yin_yang/plugins/konsole.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/yin_yang/plugins/konsole.py b/yin_yang/plugins/konsole.py index f5119c07..8f10d5d1 100644 --- a/yin_yang/plugins/konsole.py +++ b/yin_yang/plugins/konsole.py @@ -143,7 +143,22 @@ def default_profile(self): logger.warning(f'No default profile found, using {value} instead.') if value is None: - raise ValueError('No Konsole profile found.') + # create a custom profile manually + file_content = """[Appearance] +ColorScheme=Breeze + +[General] +Command=/bin/bash +Name=Fish +Parent=FALLBACK/ +""" + + with (self.user_path / 'Default.profile').open('w') as file: + file.writelines(file_content) + + self.default_profile = 'Default.profile' + + return 'Default.profile' return value @@ -190,9 +205,6 @@ def update_profile(self, dark: bool, theme: str): profile_config.write(file) def create_profiles(self): - if not self.default_profile: - raise ValueError('No default profile found.') - logger.debug('Creating new profiles for live-switching between light and dark themes.') # copy default profile to create theme profiles light_profile = self.user_path / 'Light.profile' From c15be16d1aaa4788d03070c42467261186cb1c6c Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Jul 2023 17:24:17 +0200 Subject: [PATCH 27/35] Log an error if filename contains # #199 --- yin_yang/plugins/wallpaper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index 7be015c8..ea88ae68 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -1,5 +1,6 @@ import logging import subprocess +from pathlib import Path from PySide6.QtWidgets import QDialogButtonBox, QVBoxLayout, QWidget, QLineEdit from PySide6.QtDBus import QDBusConnection, QDBusMessage @@ -64,6 +65,10 @@ def __init__(self): super().__init__() def set_theme(self, theme: str): + filename = Path(theme).name + if "#" in filename: + logger.error("Image files that contain a # will not work.") + connection = QDBusConnection.sessionBus() message = QDBusMessage.createMethodCall( 'org.kde.plasmashell', From 1ce4e480b08bc04f513a4b6bb01f7e90ead5f5c9 Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Jul 2023 17:45:08 +0200 Subject: [PATCH 28/35] Show errors from the console as notifications --- yin_yang/NotificationHandler.py | 9 +++++++++ yin_yang/__main__.py | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 yin_yang/NotificationHandler.py diff --git a/yin_yang/NotificationHandler.py b/yin_yang/NotificationHandler.py new file mode 100644 index 00000000..6f5a3974 --- /dev/null +++ b/yin_yang/NotificationHandler.py @@ -0,0 +1,9 @@ +import subprocess +from logging import Handler + + +class NotificationHandler(Handler): + """Shows logs as notifications""" + def emit(self, record): + subprocess.call(['notify-send', record.levelname, record.msg, + '-a', 'Yin & Yang', '-u', 'low', '--icon', 'yin_yang']) diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py index 2ef272a4..597fc1b7 100755 --- a/yin_yang/__main__.py +++ b/yin_yang/__main__.py @@ -12,6 +12,7 @@ from PySide6.QtWidgets import QSystemTrayIcon, QMenu from systemd import journal +from NotificationHandler import NotificationHandler from yin_yang import daemon_handler from yin_yang.meta import ConfigEvent from yin_yang import theme_switcher @@ -22,6 +23,10 @@ def setup_logger(use_systemd_journal: bool): + notification_handler = NotificationHandler() + notification_handler.addFilter(lambda record: record.levelno > logging.WARNING) + logger.addHandler(notification_handler) + if use_systemd_journal: logger.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER='yin_yang')) From 644e1bbb93de93fc891f05007f8bc16a3802a8b4 Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Jul 2023 17:52:21 +0200 Subject: [PATCH 29/35] Move filename check to setter methods --- yin_yang/plugins/wallpaper.py | 36 +++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index ea88ae68..d617f571 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -58,17 +58,45 @@ def available(self) -> bool: return test_gnome_availability(self.command) +def check_theme(theme: str) -> bool: + file = Path(theme) + if "#" in file.name: + logger.error('Image files that contain a \'#\' will not work.') + return False + if not file.exists(): + logger.error(f'Image {theme} does not exist!') + return False + + return True + + class _Kde(Plugin): name = 'Wallpaper' def __init__(self): super().__init__() + self._theme_light = None + self._theme_dark = None - def set_theme(self, theme: str): - filename = Path(theme).name - if "#" in filename: - logger.error("Image files that contain a # will not work.") + @property + def theme_light(self) -> str: + return self._theme_light + @theme_light.setter + def theme_light(self, value: str): + check_theme(value) + self._theme_light = value + + @property + def theme_dark(self) -> str: + return self._theme_dark + + @theme_dark.setter + def theme_dark(self, value: str): + check_theme(value) + self._theme_dark = value + + def set_theme(self, theme: str): connection = QDBusConnection.sessionBus() message = QDBusMessage.createMethodCall( 'org.kde.plasmashell', From ae348ec46ace4d9ba4fd12a9c569a2b663e6d47b Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 7 Oct 2023 11:28:35 +0200 Subject: [PATCH 30/35] Update pyside6 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 98ba4ba7..a8e71069 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ psutil==5.9.5 -PySide6==6.5.0 -PySide6-Addons==6.5.0 +PySide6==6.5.3 +PySide6-Addons==6.5.3 suntime==1.2.5 systemd-python==235 requests~=2.28.2 \ No newline at end of file From 9ee83162202c2cdd03ea5e16e51261f693aa5230 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 7 Oct 2023 11:47:03 +0200 Subject: [PATCH 31/35] Create venv for dependency installation Fix #217 --- README.md | 7 ++----- resources/yin-yang | 4 +++- scripts/install.sh | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7893ffcb..4d01b05f 100755 --- a/README.md +++ b/README.md @@ -68,13 +68,10 @@ Then you can install Yin-Yang in a python virtual environment: ```bash # bash is necessary to run the source command bash -# Removes any already present Yin-Yang code -rm -rf Yin-Yang # Clones the code to your local machine git clone https://github.com/oskarsh/Yin-Yang.git -# Enters the directory containing Yin-Yang's code -if pwd != "Yin-Yang"; then cd Yin-Yang; fi -## Creates a virtual environment for pypi (pip) packages +cd Yin-Yang +## Creates virtual environment for pypi packages python3 -m venv .venv source .venv/bin/activate # Installs pip requirements specified in repository diff --git a/resources/yin-yang b/resources/yin-yang index c01d529d..a5181b56 100755 --- a/resources/yin-yang +++ b/resources/yin-yang @@ -1,3 +1,5 @@ #!/bin/bash -cd /opt/yin-yang/ || exit +cd /opt/yin-yang/ || exit 1 +# check whether the activate script is readable, then activate the venv +[[ -r .venv/bin/activate ]] && source .venv/bin/activate python3 -Om yin_yang "$@" diff --git a/scripts/install.sh b/scripts/install.sh index 1f691161..0628474c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -14,7 +14,11 @@ echo "Uninstalling old version, if it exists" ./scripts/uninstall.sh echo "Installing dependencies …" +# create virtual environment +python3 -m venv /opt/yin-yang/.venv +source .venv/bin/activate pip3 install -r requirements.txt + echo "Installing yin yang" #check if /opt/ directory exists else create if [ ! -d /opt/ ]; then From d9a1c53735818ffe1e09b6f1f3d2805f546a5b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20J=C4=99drusiak?= <40692851+jakub-jedrusiak@users.noreply.github.com> Date: Tue, 1 Aug 2023 21:56:55 +0200 Subject: [PATCH 32/35] debug start --- yin_yang/__main__.py | 2 +- yin_yang/plugins/wallpaper.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/yin_yang/__main__.py b/yin_yang/__main__.py index 597fc1b7..c5d248f4 100755 --- a/yin_yang/__main__.py +++ b/yin_yang/__main__.py @@ -12,7 +12,7 @@ from PySide6.QtWidgets import QSystemTrayIcon, QMenu from systemd import journal -from NotificationHandler import NotificationHandler +from yin_yang.NotificationHandler import NotificationHandler from yin_yang import daemon_handler from yin_yang.meta import ConfigEvent from yin_yang import theme_switcher diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index d617f571..d6c6c303 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -59,6 +59,8 @@ def available(self) -> bool: def check_theme(theme: str) -> bool: + if not theme: + return False file = Path(theme) if "#" in file.name: logger.error('Image files that contain a \'#\' will not work.') From 1b5667dbc9b5647432025ee1ee6aa7634cd1da55 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 7 Oct 2023 12:12:13 +0200 Subject: [PATCH 33/35] Switch theme during suspend Fix #216 --- resources/yin_yang.service | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/yin_yang.service b/resources/yin_yang.service index d3d2b781..d091623f 100644 --- a/resources/yin_yang.service +++ b/resources/yin_yang.service @@ -1,5 +1,6 @@ [Unit] Description=Automatic light and dark mode +After=suspend.target [Service] ExecStart=/usr/bin/yin-yang --systemd From 14141643fd14a3a269e758fd26074ddeec638851 Mon Sep 17 00:00:00 2001 From: l0drex Date: Sat, 7 Oct 2023 12:13:03 +0200 Subject: [PATCH 34/35] Fix installing in wrong directory --- scripts/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 0628474c..f7801710 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -17,7 +17,8 @@ echo "Installing dependencies …" # create virtual environment python3 -m venv /opt/yin-yang/.venv source .venv/bin/activate -pip3 install -r requirements.txt +/opt/yin-yang/.venv/bin/pip3 install --upgrade setuptools pip wheel +/opt/yin-yang/.venv/bin/pip3 install -r requirements.txt echo "Installing yin yang" #check if /opt/ directory exists else create From e21836e7be745dc183a10e59fdd893188fe21e89 Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 10 Nov 2023 13:09:55 +0100 Subject: [PATCH 35/35] Remove duplicated dependency installation --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4d01b05f..7798c536 100755 --- a/README.md +++ b/README.md @@ -71,15 +71,17 @@ bash # Clones the code to your local machine git clone https://github.com/oskarsh/Yin-Yang.git cd Yin-Yang -## Creates virtual environment for pypi packages -python3 -m venv .venv -source .venv/bin/activate -# Installs pip requirements specified in repository -pip3 install -r requirements.txt # Installs Yin-Yang ./scripts/install.sh ``` +For development, skip the install and instead create a venv in your home directory: +```bash +python -m venv .venv +source .venv/bin/activate # this is for bash, there are similar scripts in the that directory for other shells like fish +pip install -r requirements.txt +``` + ## Documentation Want to help out? Check out the wiki to learn how to contribute translations, plugins and more!