Skip to content

Commit 1902eed

Browse files
authored
Merge pull request #263 from SlowNicoFish/add_budgie_support
Add budgie support
2 parents eb21c76 + 0684f71 commit 1902eed

File tree

6 files changed

+99
-1
lines changed

6 files changed

+99
-1
lines changed

yin_yang/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def get_desktop() -> Desktop:
121121
desktop = ''
122122

123123
match desktop.lower():
124-
case 'gnome' | 'budgie':
124+
case 'gnome':
125125
return Desktop.GNOME
126126
case 'kde' | 'plasma' | 'plasma5':
127127
return Desktop.KDE
@@ -133,6 +133,8 @@ def get_desktop() -> Desktop:
133133
return Desktop.CINNAMON
134134
case 'sway' | 'hyprland':
135135
return Desktop.GNOME
136+
case 'budgie:gnome' | 'budgie-desktop' | 'budgie':
137+
return Desktop.BUDGIE
136138
case _:
137139
return Desktop.UNKNOWN
138140

yin_yang/meta.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Desktop(Enum):
1616
UNKNOWN = 'unknown'
1717
MATE = 'mate'
1818
CINNAMON = 'cinnamon'
19+
BUDGIE = 'budgie'
1920

2021

2122
class PluginKey(Enum):

yin_yang/plugins/gtk.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def __init__(self, desktop: Desktop):
3333
super().__init__(_Xfce())
3434
case Desktop.CINNAMON:
3535
super().__init__(_Cinnamon())
36+
case Desktop.BUDGIE:
37+
super().__init__(_Budgie())
3638
case _:
3739
super().__init__(None)
3840

@@ -61,6 +63,19 @@ def __init__(self):
6163
@property
6264
def available(self) -> bool:
6365
return test_gnome_availability(self.command)
66+
67+
68+
class _Budgie(PluginCommandline):
69+
name = 'GTK'
70+
71+
def __init__(self):
72+
super().__init__(['gsettings', 'set', 'org.gnome.desktop.interface', 'gtk-theme', '{theme}'])
73+
self.theme_light = 'Default'
74+
self.theme_dark = 'Default'
75+
76+
@property
77+
def available(self) -> bool:
78+
return test_gnome_availability(self.command)
6479

6580

6681
class _Kde(DBusPlugin):

yin_yang/plugins/icons.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from .system import test_gnome_availability
22
from ..meta import Desktop
33
from ._plugin import PluginDesktopDependent, PluginCommandline
4+
from pathlib import Path
5+
from os import scandir, path
6+
7+
theme_directories = ['/usr/share/icons', f'{Path.home()}/.icons']
48

59

610
class Icons(PluginDesktopDependent):
@@ -10,6 +14,8 @@ def __init__(self, desktop: Desktop):
1014
super().__init__(_Mate())
1115
case Desktop.CINNAMON:
1216
super().__init__(_Cinnamon())
17+
case Desktop.BUDGIE:
18+
super().__init__(_Budgie())
1319
case _:
1420
super().__init__(None)
1521

@@ -34,3 +40,27 @@ def __init__(self):
3440
@property
3541
def available(self) -> bool:
3642
return test_gnome_availability(self.command)
43+
44+
45+
class _Budgie(PluginCommandline):
46+
def __init__(self):
47+
super().__init__(['gsettings', 'set', 'org.gnome.desktop.interface', 'icon-theme', '\"{theme}\"'])
48+
self.theme_light = 'Default'
49+
self.theme_dark = 'Default'
50+
51+
@property
52+
def available(self) -> bool:
53+
return test_gnome_availability(self.command)
54+
55+
@property
56+
def available_themes(self) -> dict:
57+
themes = []
58+
59+
for directory in theme_directories:
60+
if not path.isdir(directory):
61+
continue
62+
63+
with scandir(directory) as entries:
64+
themes.extend(d.name for d in entries if d.is_dir() and path.isfile(d.path + '/index.theme'))
65+
66+
return {t: t for t in themes}

yin_yang/plugins/system.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def __init__(self, desktop: Desktop):
3131
super().__init__(_Mate())
3232
case Desktop.CINNAMON:
3333
super().__init__(_Cinnamon())
34+
case Desktop.BUDGIE:
35+
super().__init__(_Budgie())
3436
case _:
3537
super().__init__(None)
3638

@@ -48,6 +50,41 @@ def available(self) -> bool:
4850
return test_gnome_availability(self.command)
4951

5052

53+
class _Budgie(PluginCommandline):
54+
name = 'System'
55+
56+
def __init__(self):
57+
super().__init__(['gsettings', 'set', 'com.solus-project.budgie-panel', 'dark-theme', '{theme}'])
58+
self.theme_light = 'light'
59+
self.theme_dark = 'dark'
60+
61+
@property
62+
def available(self) -> bool:
63+
return test_gnome_availability(self.command)
64+
65+
# Override because budgie uses a switch for dark/light mode
66+
def insert_theme(self, theme: str) -> list:
67+
command = self.command.copy()
68+
match theme.lower():
69+
case 'dark':
70+
theme_bool = 'true'
71+
case 'light':
72+
theme_bool = 'false'
73+
case _:
74+
raise NotImplementedError
75+
76+
for i, arg in enumerate(command):
77+
command[i] = arg.format(theme=theme_bool)
78+
79+
return command
80+
81+
@property
82+
def available_themes(self) -> dict:
83+
themes: dict[str, str] = {'dark': 'Dark', 'light': 'Light'}
84+
85+
return themes
86+
87+
5188
def get_readable_kde_theme_name(file) -> str:
5289
"""Searches for the long_name in the file and maps it to the found short name"""
5390

yin_yang/plugins/wallpaper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def __init__(self, desktop: Desktop):
2626
super().__init__(_Xfce())
2727
case Desktop.CINNAMON:
2828
super().__init__(_Cinnamon())
29+
case Desktop.BUDGIE:
30+
super().__init__(_Budgie())
2931
case _:
3032
super().__init__(None)
3133

@@ -60,6 +62,17 @@ def available(self) -> bool:
6062
return test_gnome_availability(self.command)
6163

6264

65+
class _Budgie(PluginCommandline):
66+
name = 'Wallpaper'
67+
68+
def __init__(self):
69+
super().__init__(['gsettings', 'set', 'org.gnome.desktop.background', 'picture-uri', 'file://{theme}'])
70+
71+
@property
72+
def available(self) -> bool:
73+
return test_gnome_availability(self.command)
74+
75+
6376
def check_theme(theme: str) -> bool:
6477
if not theme:
6578
return False

0 commit comments

Comments
 (0)