forked from Pippadi/libadwaita-theme-changer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibadwaita-tc.py
executable file
·76 lines (67 loc) · 2.47 KB
/
libadwaita-tc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/python3
############################################
#
# Libadwaita Theme Changer
# created by OdzioM
#
############################################
import sys
import os
ThemeItems = ["gtk-4.0/gtk.css", "gtk-4.0/gtk-dark.css", "gtk-4.0/assets", "assets"]
def removeIfExists(path):
if os.path.islink(path):
print(path)
os.remove(path)
def removeCurrentTheme(conf_dir):
for item in ThemeItems:
removeIfExists(os.path.join(conf_dir, item))
def setNewTheme(theme_dir, conf_dir):
for item in ThemeItems:
os.symlink(os.path.join(theme_dir, item), os.path.join(conf_dir, item))
if __name__ == "__main__":
abs_home_dir = os.getenv('HOME')
rel_config_dir = ".config"
local_share_dir = ".local/share/themes"
dot_themes_dir = ".themes"
usr_themes_dir = "/usr/share/themes"
rel_themes_dir = str()
print("Select theme folder: ")
print(f'1. {local_share_dir}')
print(f'2. {dot_themes_dir}')
print(f'3. {usr_themes_dir}')
opt = input("Choose your theme folder: ")
match opt:
case "1":
rel_themes_dir = local_share_dir
case "2":
rel_themes_dir = dot_themes_dir
case "3":
rel_themes_dir = usr_themes_dir
case _:
raise ValueError()
abs_config_dir = os.path.join(abs_home_dir, rel_config_dir)
abs_themes_dir = os.path.join(abs_home_dir, rel_themes_dir)
if "--reset" in sys.argv:
print(f'\n***\nResetting theme to default!\n***\n')
removeCurrentTheme(abs_config_dir)
else:
all_themes = os.listdir(abs_themes_dir)
print("Select theme: ")
for i, theme in enumerate(all_themes):
print(f'{i+1}. {theme}')
print("Anything else to exit")
chk = input("Your choice: ")
if chk.isdigit() and int(chk) <= len(all_themes):
chk_value = int(chk)-1
chk_theme = all_themes[chk_value]
print(f'\n***\nChose {chk_theme}\n***\n')
print("Removing previous theme...")
removeCurrentTheme(abs_config_dir)
print("Installing new theme...")
setNewTheme(os.path.join(abs_themes_dir, chk_theme), abs_config_dir)
print("Setting new theme...")
os.system(f'gsettings set org.gnome.desktop.interface gtk-theme "{chk_theme}"')
os.system(f'gsettings set org.gnome.desktop.wm.preferences theme "{chk_theme}"')
print("Done.")
else:
print("Bye bye!")