Skip to content

Commit

Permalink
Merge pull request #263 from SlowNicoFish/add_budgie_support
Browse files Browse the repository at this point in the history
Add budgie support
  • Loading branch information
l0drex authored Feb 13, 2024
2 parents eb21c76 + 0684f71 commit 1902eed
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yin_yang/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions yin_yang/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Desktop(Enum):
UNKNOWN = 'unknown'
MATE = 'mate'
CINNAMON = 'cinnamon'
BUDGIE = 'budgie'


class PluginKey(Enum):
Expand Down
15 changes: 15 additions & 0 deletions yin_yang/plugins/gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down
30 changes: 30 additions & 0 deletions yin_yang/plugins/icons.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)

Expand All @@ -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}
37 changes: 37 additions & 0 deletions yin_yang/plugins/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"""

Expand Down
13 changes: 13 additions & 0 deletions yin_yang/plugins/wallpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1902eed

Please sign in to comment.