From d02dd6558244f0e2b644f07caea3d4d28bcc2bf7 Mon Sep 17 00:00:00 2001 From: l0drex Date: Thu, 6 Apr 2023 21:05:44 +0200 Subject: [PATCH 01/17] Write migration for konsole changes --- src/config.py | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index 5e953e28..c40da063 100755 --- a/src/config.py +++ b/src/config.py @@ -2,19 +2,22 @@ import logging import os import pathlib +import re from abc import ABC, abstractmethod +from configparser import ConfigParser +from datetime import time from functools import cache +from shutil import copy2 from time import sleep +from typing import Union, Optional from PySide6.QtCore import QObject from PySide6.QtPositioning import QGeoPositionInfoSource, QGeoPositionInfo, QGeoCoordinate from psutil import process_iter, NoSuchProcess -from datetime import time -from typing import Union, Optional - from suntime import Sun, SunTimeException -from src.plugins import get_plugins + from src.meta import Modes, Desktop, PluginKey, ConfigEvent +from src.plugins import get_plugins logger = logging.getLogger(__name__) @@ -71,6 +74,44 @@ def update_config(config_old: dict, defaults: dict): plugin_settings: dict = defaults['plugins'] for plugin_name, plugin_config in plugin_settings.items(): update_plugin_config(config_old, plugin_config, plugin_name) + if config_old['version'] <= 3.2: + # migrate konsole settings by creating a profile and setting the desired theme + + # copy current profile to create a dark theme profile + # cant use config parser because of weird file structure + with open(pathlib.Path.home() / '.config/konsolerc', 'r') as file: + for line in file: + # Search for the pattern "DefaultProfile=*" + match = re.search(r'DefaultProfile=(.*)', line) + + # If a match is found, return the content of the wildcard '*' + if match: + default_profile = match.group(1) + break + + dark_profile = default_profile.replace('.profile', ' dark.profile') + + konsole_path = pathlib.Path.home() / '.local/share/konsole' + # there is a parent profile section in the profile file, maybe we can use that (in a later version)? + copy2(konsole_path / default_profile, + konsole_path / dark_profile) + + # Change name in file + profile_config = ConfigParser() + profile_config.optionxform = str + profile_config.read(konsole_path / dark_profile) + profile_config['General']['Name'] = dark_profile.removesuffix('.profile') + + # set theme in both copies + profile_config['Appearance']['ColorScheme'] = config_old['plugins']['konsole']['dark_theme'] + with open(konsole_path / dark_profile, 'w') as file: + profile_config.write(file) + + profile_config.read(konsole_path / default_profile) + profile_config['Appearance']['ColorScheme'] = config_old['plugins']['konsole']['light_theme'] + with open(konsole_path / default_profile, 'w') as file: + profile_config.write(file) + return config_new From fe296c16927aa3aab791f9288f7ab4b8da1650e7 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 22:50:01 +0200 Subject: [PATCH 02/17] Overhauled the whole konsole theme change process There are now a light and a dark profile, rather than one profile for each theme. --- src/config.py | 42 +----------- src/plugins/konsole.py | 144 +++++++++++++++++++++++++++++++++++------ 2 files changed, 126 insertions(+), 60 deletions(-) diff --git a/src/config.py b/src/config.py index c40da063..e74c2cbe 100755 --- a/src/config.py +++ b/src/config.py @@ -2,12 +2,9 @@ import logging import os import pathlib -import re from abc import ABC, abstractmethod -from configparser import ConfigParser from datetime import time from functools import cache -from shutil import copy2 from time import sleep from typing import Union, Optional @@ -74,43 +71,6 @@ def update_config(config_old: dict, defaults: dict): plugin_settings: dict = defaults['plugins'] for plugin_name, plugin_config in plugin_settings.items(): update_plugin_config(config_old, plugin_config, plugin_name) - if config_old['version'] <= 3.2: - # migrate konsole settings by creating a profile and setting the desired theme - - # copy current profile to create a dark theme profile - # cant use config parser because of weird file structure - with open(pathlib.Path.home() / '.config/konsolerc', 'r') as file: - for line in file: - # Search for the pattern "DefaultProfile=*" - match = re.search(r'DefaultProfile=(.*)', line) - - # If a match is found, return the content of the wildcard '*' - if match: - default_profile = match.group(1) - break - - dark_profile = default_profile.replace('.profile', ' dark.profile') - - konsole_path = pathlib.Path.home() / '.local/share/konsole' - # there is a parent profile section in the profile file, maybe we can use that (in a later version)? - copy2(konsole_path / default_profile, - konsole_path / dark_profile) - - # Change name in file - profile_config = ConfigParser() - profile_config.optionxform = str - profile_config.read(konsole_path / dark_profile) - profile_config['General']['Name'] = dark_profile.removesuffix('.profile') - - # set theme in both copies - profile_config['Appearance']['ColorScheme'] = config_old['plugins']['konsole']['dark_theme'] - with open(konsole_path / dark_profile, 'w') as file: - profile_config.write(file) - - profile_config.read(konsole_path / default_profile) - profile_config['Appearance']['ColorScheme'] = config_old['plugins']['konsole']['light_theme'] - with open(konsole_path / default_profile, 'w') as file: - profile_config.write(file) return config_new @@ -377,7 +337,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, diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 70183d89..bd06d65b 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -1,7 +1,11 @@ import logging import os +import re import subprocess +from configparser import ConfigParser +from itertools import chain from pathlib import Path +from shutil import copy2, copyfile import psutil from PySide6.QtDBus import QDBusConnection, QDBusMessage @@ -18,6 +22,7 @@ class Konsole(Plugin): This is necessary to allow live theme changes. """ global_path = Path('/usr/share/konsole') + config_path = Path.home() / '.config/konsolerc' @property def user_path(self) -> Path: @@ -25,10 +30,36 @@ def user_path(self) -> Path: def __init__(self): super().__init__() - self.theme_light = 'BlackOnWhite' - self.theme_dark = 'Breeze' + self._theme_light = 'BlackOnWhite' + self._theme_dark = 'Breeze' + + @property + def theme_light(self): + return self._theme_light + + @theme_light.setter + def theme_light(self, value): + self.update_profile(False, value) + self._theme_light = value + + @property + def theme_dark(self): + return self._theme_dark + + @theme_dark.setter + def theme_dark(self, value): + self.update_profile(True, value) + self._theme_dark = value + + def set_mode(self, dark: bool) -> bool: + # run checks + result = super().set_mode(dark) + + profile = 'Dark' if dark else 'Light' + + # update default profile, if application is started afterward + self.default_profile = profile - def set_theme(self, theme: str): # Set Konsole profile for all sessions # Get the process IDs of all running Konsole instances owned by the current user @@ -39,36 +70,110 @@ def set_theme(self, theme: str): # loop: console processes for proc_id in process_ids: - set_profile(f'org.kde.konsole-{proc_id}', theme) + logger.debug(f'Changing profile in konsole session {proc_id}') + set_profile(f'org.kde.konsole-{proc_id}', profile) + + set_profile('org.kde.yakuake', profile) + + return result - set_profile('org.kde.yakuake', theme) + def set_theme(self, theme: str): + # everything is done in set_mode (above) + pass @property def available_themes(self) -> dict: if not self.available: return {} - profile_paths = [ - p.name.removesuffix('.profile') for p in self.user_path.iterdir() - if p.is_file() and p.suffix == '.profile' - ] + themes = dict(sorted([ + (p.with_suffix('').name, p) + for p in chain(self.global_path.iterdir(), self.user_path.iterdir()) + if p.is_file() and p.suffix == '.colorscheme' + ])) - return {profile: profile for profile in profile_paths} + themes_dict = {} + config_parser = ConfigParser() - def get_input(self, widget): - input_widgets = super().get_input(widget) - for widget in input_widgets: - widget.setToolTip( - 'Select a profile. ' - 'Create new profiles or edit existing ones within Konsole to change the color scheme.' - ) + for theme, theme_path in themes.items(): + config_parser.read(theme_path) + theme_name = config_parser['General']['Description'] + themes_dict[theme] = theme_name - return input_widgets + assert themes_dict != {}, 'No themes found!' + return themes_dict @property def available(self) -> bool: return self.global_path.is_dir() + @property + def default_profile(self): + # cant use config parser because of weird file structure + with self.config_path.open('r') as file: + for line in file: + # Search for the pattern "DefaultProfile=*" + match = re.search(r'DefaultProfile=(.*)', line) + + # If a match is found, return the content of the wildcard '*' + if match: + return match.group(1) + + @default_profile.setter + def default_profile(self, value): + with self.config_path.open('r') as file: + lines = file.readlines() + for i, line in enumerate(lines): + # Search for the pattern "DefaultProfile=*" + match = re.search(r'DefaultProfile=(.*)', line) + + # If a match is found, return the content of the wildcard '*' + if match: + lines[i] = f'DefaultProfile={value}\n' + break + with self.config_path.open('w') as file: + file.writelines(lines) + + def update_profile(self, dark: bool, theme: str): + # update the color scheme setting in either dark or light profile + logger.debug('Updating konsole profile') + + file_path = self.user_path / ('Dark.profile' if dark else 'Light.profile') + if not file_path.exists(): + self.create_profiles() + + profile_config = ConfigParser() + profile_config.optionxform = str + profile_config.read(file_path) + profile_config['Appearance']['ColorScheme'] = theme + with open(file_path, 'w') as file: + profile_config.write(file) + + def create_profiles(self): + 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' + dark_profile = self.user_path / 'Dark.profile' + # TODO there is a parent profile section in the profile file, maybe we can use that (in a later version)? + copyfile(self.user_path / self.default_profile, light_profile) + copyfile(self.user_path / self.default_profile, dark_profile) + + # Change name in file + profile_config = ConfigParser() + profile_config.optionxform = str + + profile_config.read(self.user_path / light_profile) + profile_config['General']['Name'] = light_profile.stem + + with open(light_profile, 'w') as file: + profile_config.write(file) + + profile_config.read(self.user_path / dark_profile) + profile_config['General']['Name'] = dark_profile.stem + + with open(dark_profile, 'w') as file: + profile_config.write(file) + def set_profile(service: str, profile: str): # connect to the session bus @@ -80,6 +185,7 @@ def set_profile(service: str, profile: str): # loop: process sessions for session in sessions: + logger.debug(f'Changing profile of session {session} to {profile}') # set profile message = QDBusMessage.createMethodCall( service, @@ -88,4 +194,4 @@ def set_profile(service: str, profile: str): 'setProfile' ) message.setArguments([profile]) - connection.call(message) + response = connection.call(message) From 6157832aefd4f110278efae94a7c9419b06b9f86 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 22:56:38 +0200 Subject: [PATCH 03/17] Fix #184 --- src/yin_yang.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yin_yang.py b/src/yin_yang.py index 7106077b..429ca55d 100755 --- a/src/yin_yang.py +++ b/src/yin_yang.py @@ -1,4 +1,3 @@ - """ title: yin_yang description: yin_yang provides an easy way to toggle between light and dark @@ -13,6 +12,8 @@ import time from threading import Thread +from plugins.notify import Notification +from plugins.sound import Sound from src.daemon_handler import update_times from src.meta import PluginKey from src.config import config, plugins @@ -38,7 +39,8 @@ def set_mode(dark: bool, force=False): logger.info(f'Switching to {"dark" if dark else "light"} mode.') for p in plugins: - if config.get_plugin_key(p.name, PluginKey.ENABLED): + if config.get_plugin_key(p.name, PluginKey.ENABLED) and \ + (force and (isinstance(p, Sound) or isinstance(p, Notification))): # skip sound and notify on apply settings try: logger.info(f'Changing theme in plugin {p.name}') p_thread = Thread(target=p.set_mode, args=[dark], name=p.name) From 40ef2fafdee3f203384df0e1cb48efdecbe20a21 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 23:24:18 +0200 Subject: [PATCH 04/17] Fix the fix of #184 --- src/yin_yang.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yin_yang.py b/src/yin_yang.py index 429ca55d..3b18afdb 100755 --- a/src/yin_yang.py +++ b/src/yin_yang.py @@ -39,8 +39,10 @@ def set_mode(dark: bool, force=False): logger.info(f'Switching to {"dark" if dark else "light"} mode.') for p in plugins: - if config.get_plugin_key(p.name, PluginKey.ENABLED) and \ - (force and (isinstance(p, Sound) or isinstance(p, Notification))): # skip sound and notify on apply settings + if config.get_plugin_key(p.name, PluginKey.ENABLED): + if force and (isinstance(p, Sound) or isinstance(p, Notification)): + # skip sound and notify on apply settings + continue try: logger.info(f'Changing theme in plugin {p.name}') p_thread = Thread(target=p.set_mode, args=[dark], name=p.name) From 9eddd307941fbeee2293358510674bd3bdcd16df Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 23:24:33 +0200 Subject: [PATCH 05/17] Change dolphin konsole profiles as well --- src/plugins/konsole.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index bd06d65b..267d881e 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -75,6 +75,16 @@ 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() + ] + + # loop: console processes + for proc_id in process_ids: + logger.debug(f'Changing profile in dolphin session {proc_id}') + set_profile(f'org.kde.dolphin-{proc_id}', profile) + return result def set_theme(self, theme: str): From 12bd3539fce86362437280596e6b544a901dffcb Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 23:28:42 +0200 Subject: [PATCH 06/17] Fix the test --- src/plugins/konsole.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 267d881e..fa29abc4 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -145,6 +145,9 @@ def default_profile(self, value): file.writelines(lines) def update_profile(self, dark: bool, theme: str): + if not self.available: + return + # update the color scheme setting in either dark or light profile logger.debug('Updating konsole profile') @@ -172,13 +175,13 @@ def create_profiles(self): profile_config = ConfigParser() profile_config.optionxform = str - profile_config.read(self.user_path / light_profile) + profile_config.read(light_profile) profile_config['General']['Name'] = light_profile.stem with open(light_profile, 'w') as file: profile_config.write(file) - profile_config.read(self.user_path / dark_profile) + profile_config.read(dark_profile) profile_config['General']['Name'] = dark_profile.stem with open(dark_profile, 'w') as file: From 17c3c9a5372eb699b7fa2830406c052878baf1d6 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 23:31:36 +0200 Subject: [PATCH 07/17] Fix import --- src/yin_yang.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yin_yang.py b/src/yin_yang.py index 3b18afdb..ebb2c971 100755 --- a/src/yin_yang.py +++ b/src/yin_yang.py @@ -12,8 +12,8 @@ import time from threading import Thread -from plugins.notify import Notification -from plugins.sound import Sound +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 e5f638756c5683cdf1f4dd475c8dabeb4657894e Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 17 Apr 2023 23:37:29 +0200 Subject: [PATCH 08/17] Fix guards of set_mode in konsole --- src/plugins/konsole.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index fa29abc4..ba57f5ac 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -53,7 +53,8 @@ def theme_dark(self, value): def set_mode(self, dark: bool) -> bool: # run checks - result = super().set_mode(dark) + if not super().set_mode(dark): + return False profile = 'Dark' if dark else 'Light' @@ -85,7 +86,7 @@ def set_mode(self, dark: bool) -> bool: logger.debug(f'Changing profile in dolphin session {proc_id}') set_profile(f'org.kde.dolphin-{proc_id}', profile) - return result + return True def set_theme(self, theme: str): # everything is done in set_mode (above) From 120837221fa3a92c7b7aa07a275075108eeb6705 Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Apr 2023 15:23:47 +0200 Subject: [PATCH 09/17] Fix comment copy --- src/plugins/konsole.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index ba57f5ac..65b7a268 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -81,7 +81,7 @@ def set_mode(self, dark: bool) -> bool: if proc.info['name'] == 'dolphin' and proc.info['username'] == os.getlogin() ] - # loop: console processes + # loop: dolphin processes for proc_id in process_ids: logger.debug(f'Changing profile in dolphin session {proc_id}') set_profile(f'org.kde.dolphin-{proc_id}', profile) From 90426b6f1a1bfbffab3aa21b4e77b0fd3164d4fc Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Apr 2023 15:25:55 +0200 Subject: [PATCH 10/17] Fix default profile setting This fixes the wrong profile being used when opening a new window --- src/plugins/konsole.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 65b7a268..8a9f2943 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -5,7 +5,7 @@ from configparser import ConfigParser from itertools import chain from pathlib import Path -from shutil import copy2, copyfile +from shutil import copyfile import psutil from PySide6.QtDBus import QDBusConnection, QDBusMessage @@ -59,7 +59,7 @@ def set_mode(self, dark: bool) -> bool: profile = 'Dark' if dark else 'Light' # update default profile, if application is started afterward - self.default_profile = profile + self.default_profile = profile + '.profile' # Set Konsole profile for all sessions From a17855e01430219fd1bd0bc1a3fe0d55eea68277 Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Apr 2023 15:29:11 +0200 Subject: [PATCH 11/17] Return to 3.2 version --- src/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.py b/src/config.py index e74c2cbe..8db1eaca 100755 --- a/src/config.py +++ b/src/config.py @@ -337,7 +337,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.3, + 'version': 3.2, 'running': False, 'dark_mode': False, 'mode': Modes.MANUAL.value, From 2688593bf940803d9b8afdb3d6c2a955e7636205 Mon Sep 17 00:00:00 2001 From: l0drex Date: Tue, 18 Apr 2023 17:40:06 +0200 Subject: [PATCH 12/17] Fix deprecation warning --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 5ae5e72c..a1a14084 100755 --- a/main.py +++ b/main.py @@ -62,7 +62,7 @@ def main(arguments): logger.debug(f'Using language {lang}') # system translations - path = QLibraryInfo.location(QLibraryInfo.TranslationsPath) + path = QLibraryInfo.path(QLibraryInfo.TranslationsPath) translator = QTranslator(app) if translator.load(QLocale.system(), 'qtbase', '_', path): app.installTranslator(translator) From 3ca0af2330044eabc3f2be0ffdcaf87b2a7a09fa Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 24 Apr 2023 12:24:04 +0200 Subject: [PATCH 13/17] Skip updating profiles if theme is empty string Fixes crash reported in #194 --- src/plugins/konsole.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 8a9f2943..64f5107d 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -146,7 +146,8 @@ def default_profile(self, value): file.writelines(lines) def update_profile(self, dark: bool, theme: str): - if not self.available: + if not self.available or theme == '': + # theme is empty string on super init return # update the color scheme setting in either dark or light profile From 7295b705e2ce8ba04d6dd18a095a84f1a34fd383 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 24 Apr 2023 12:24:51 +0200 Subject: [PATCH 14/17] Use any profile if default profile section is missing Might fix #194 --- src/plugins/konsole.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 64f5107d..850380b2 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -120,6 +120,7 @@ def available(self) -> bool: @property def default_profile(self): + value = None # cant use config parser because of weird file structure with self.config_path.open('r') as file: for line in file: @@ -128,7 +129,20 @@ def default_profile(self): # If a match is found, return the content of the wildcard '*' if match: - return match.group(1) + value = match.group(1) + + if value is None: + # use the first found profile + for file in self.user_path.iterdir(): + if file.suffix == '.profile': + value = file.name + break + if value is not None: + logger.warning(f'No default profile found, using {value} instead.') + else: + raise ValueError('No Konsole profile found.') + + return value @default_profile.setter def default_profile(self, value): From 17ca16e4a32d0d532c5ba39ace3666e9ae5dfcd6 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 24 Apr 2023 13:18:15 +0200 Subject: [PATCH 15/17] Remove installation of systemd units They are also created by the python app. Installing them from bash caused them to have the wrong user and therefore weren't accessible by the script. --- scripts/install.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 4965d3ed..1f691161 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -44,10 +44,7 @@ cp ./resources/yin-yang /usr/bin/ cp ./resources/Yin-Yang.desktop "$USER_HOME/.local/share/applications/Yin-Yang.desktop" # copy icon cp ./resources/logo.svg /usr/share/icons/hicolor/scalable/apps/yin_yang.svg -# systemd unit files -mkdir -p "$USER_HOME/.local/share/systemd/user/" -cp ./resources/yin_yang.service "$USER_HOME/.local/share/systemd/user/yin_yang.service" -cp ./resources/yin_yang.timer "$USER_HOME/.local/share/systemd/user/yin_yang.timer" +# systemd unit files will be installed by the app cat << "EOF" __ ___ __ __ From 9b3cb63d63ead703114b3f7987a3096229a91275 Mon Sep 17 00:00:00 2001 From: l0drex Date: Mon, 24 Apr 2023 13:18:32 +0200 Subject: [PATCH 16/17] Uninstall systemd units --- scripts/uninstall.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index d31cd5ab..4f73420c 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -23,5 +23,9 @@ rm -rf /opt/yin-yang /usr/bin/yin-yang echo "Removing manifest" rm -f /usr/lib/mozilla/native-messaging-hosts/yin_yang.json +echo "Removing systemd units" +rm -f "$HOME/.local/share/systemd/user/yin_yang.timer" +rm -f "$HOME/.local/share/systemd/user/yin_yang.service" + echo Yin-Yang uninstalled succesfully echo have a nice day ... From 283af10da8d8c49fadf8db67fd523d4cceb134ff Mon Sep 17 00:00:00 2001 From: l0drex Date: Fri, 28 Apr 2023 11:40:07 +0200 Subject: [PATCH 17/17] Fix crash when dolphins konsole is not opened --- src/plugins/konsole.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/konsole.py b/src/plugins/konsole.py index 850380b2..a771248c 100644 --- a/src/plugins/konsole.py +++ b/src/plugins/konsole.py @@ -145,7 +145,9 @@ def default_profile(self): return value @default_profile.setter - def default_profile(self, value): + def default_profile(self, value: str): + assert value.endswith('.profile') + with self.config_path.open('r') as file: lines = file.readlines() for i, line in enumerate(lines): @@ -209,7 +211,12 @@ def set_profile(service: str, profile: str): connection = QDBusConnection.sessionBus() # maybe it's possible with pyside6 dbus packages, but this was simpler and worked - sessions = subprocess.check_output(f'qdbus {service} | grep "Sessions/"', shell=True) + try: + sessions = subprocess.check_output(f'qdbus {service} | grep "Sessions/"', shell=True) + except subprocess.CalledProcessError: + # happens when dolphins konsole is not opened + logger.debug(f'No Konsole sessions available in service {service}, skipping') + return sessions = sessions.decode('utf-8').removesuffix('\n').split('\n') # loop: process sessions @@ -223,4 +230,4 @@ def set_profile(service: str, profile: str): 'setProfile' ) message.setArguments([profile]) - response = connection.call(message) + connection.call(message)