diff --git a/yin_yang/config.py b/yin_yang/config.py index be1b0c2..f62d0d5 100755 --- a/yin_yang/config.py +++ b/yin_yang/config.py @@ -121,7 +121,7 @@ def get_desktop() -> Desktop: desktop = '' match desktop.lower(): - case 'gnome' | 'budgie': + case 'gnome': return Desktop.GNOME case 'kde' | 'plasma' | 'plasma5': return Desktop.KDE @@ -133,6 +133,8 @@ def get_desktop() -> Desktop: return Desktop.CINNAMON case 'sway' | 'hyprland': return Desktop.GNOME + case 'budgie:gnome' | 'budgie-desktop' | 'budgie': + return Desktop.BUDGIE case _: return Desktop.UNKNOWN diff --git a/yin_yang/meta.py b/yin_yang/meta.py index 6272adc..eae8466 100644 --- a/yin_yang/meta.py +++ b/yin_yang/meta.py @@ -16,6 +16,7 @@ class Desktop(Enum): UNKNOWN = 'unknown' MATE = 'mate' CINNAMON = 'cinnamon' + BUDGIE = 'budgie' class PluginKey(Enum): diff --git a/yin_yang/plugins/gtk.py b/yin_yang/plugins/gtk.py index 942136c..fa7a411 100755 --- a/yin_yang/plugins/gtk.py +++ b/yin_yang/plugins/gtk.py @@ -33,6 +33,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Xfce()) case Desktop.CINNAMON: super().__init__(_Cinnamon()) + case Desktop.BUDGIE: + super().__init__(_Budgie()) case _: super().__init__(None) @@ -61,6 +63,19 @@ def __init__(self): @property def available(self) -> bool: return test_gnome_availability(self.command) + + +class _Budgie(PluginCommandline): + name = 'GTK' + + def __init__(self): + super().__init__(['gsettings', 'set', 'org.gnome.desktop.interface', 'gtk-theme', '{theme}']) + self.theme_light = 'Default' + self.theme_dark = 'Default' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) class _Kde(DBusPlugin): diff --git a/yin_yang/plugins/icons.py b/yin_yang/plugins/icons.py index 3121e6c..04cf65e 100644 --- a/yin_yang/plugins/icons.py +++ b/yin_yang/plugins/icons.py @@ -1,6 +1,10 @@ from .system import test_gnome_availability from ..meta import Desktop from ._plugin import PluginDesktopDependent, PluginCommandline +from pathlib import Path +from os import scandir, path + +theme_directories = ['/usr/share/icons', f'{Path.home()}/.icons'] class Icons(PluginDesktopDependent): @@ -10,6 +14,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Mate()) case Desktop.CINNAMON: super().__init__(_Cinnamon()) + case Desktop.BUDGIE: + super().__init__(_Budgie()) case _: super().__init__(None) @@ -34,3 +40,27 @@ def __init__(self): @property def available(self) -> bool: return test_gnome_availability(self.command) + + +class _Budgie(PluginCommandline): + def __init__(self): + super().__init__(['gsettings', 'set', 'org.gnome.desktop.interface', 'icon-theme', '\"{theme}\"']) + self.theme_light = 'Default' + self.theme_dark = 'Default' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) + + @property + def available_themes(self) -> dict: + themes = [] + + for directory in theme_directories: + if not path.isdir(directory): + continue + + with scandir(directory) as entries: + themes.extend(d.name for d in entries if d.is_dir() and path.isfile(d.path + '/index.theme')) + + return {t: t for t in themes} diff --git a/yin_yang/plugins/system.py b/yin_yang/plugins/system.py index f5c2710..c58bb14 100644 --- a/yin_yang/plugins/system.py +++ b/yin_yang/plugins/system.py @@ -31,6 +31,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Mate()) case Desktop.CINNAMON: super().__init__(_Cinnamon()) + case Desktop.BUDGIE: + super().__init__(_Budgie()) case _: super().__init__(None) @@ -48,6 +50,41 @@ def available(self) -> bool: return test_gnome_availability(self.command) +class _Budgie(PluginCommandline): + name = 'System' + + def __init__(self): + super().__init__(['gsettings', 'set', 'com.solus-project.budgie-panel', 'dark-theme', '{theme}']) + self.theme_light = 'light' + self.theme_dark = 'dark' + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) + + # Override because budgie uses a switch for dark/light mode + def insert_theme(self, theme: str) -> list: + command = self.command.copy() + match theme.lower(): + case 'dark': + theme_bool = 'true' + case 'light': + theme_bool = 'false' + case _: + raise NotImplementedError + + for i, arg in enumerate(command): + command[i] = arg.format(theme=theme_bool) + + return command + + @property + def available_themes(self) -> dict: + themes: dict[str, str] = {'dark': 'Dark', 'light': 'Light'} + + return themes + + def get_readable_kde_theme_name(file) -> str: """Searches for the long_name in the file and maps it to the found short name""" diff --git a/yin_yang/plugins/wallpaper.py b/yin_yang/plugins/wallpaper.py index 41fcf1e..c91b797 100755 --- a/yin_yang/plugins/wallpaper.py +++ b/yin_yang/plugins/wallpaper.py @@ -26,6 +26,8 @@ def __init__(self, desktop: Desktop): super().__init__(_Xfce()) case Desktop.CINNAMON: super().__init__(_Cinnamon()) + case Desktop.BUDGIE: + super().__init__(_Budgie()) case _: super().__init__(None) @@ -60,6 +62,17 @@ def available(self) -> bool: return test_gnome_availability(self.command) +class _Budgie(PluginCommandline): + name = 'Wallpaper' + + def __init__(self): + super().__init__(['gsettings', 'set', 'org.gnome.desktop.background', 'picture-uri', 'file://{theme}']) + + @property + def available(self) -> bool: + return test_gnome_availability(self.command) + + def check_theme(theme: str) -> bool: if not theme: return False