-
Notifications
You must be signed in to change notification settings - Fork 1
/
eOSdock-themeswitcher.sh
executable file
·61 lines (52 loc) · 1.64 KB
/
eOSdock-themeswitcher.sh
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
#!/bin/bash
set -euo pipefail
# Manage dock themes
#========================
# VARIABLES =
#========================
IMPORTFILE="Docktheme.css"
#========================
# FUNCTIONS =
#========================
# add an import to gtk.css so it can apply stuff
function enable_theme()
{
if ! grep -q "@import \"$IMPORTFILE\";" ~/.config/gtk-4.0/gtk.css
then
echo "import line not present in gtk.css. Adding."
echo '/* Import line for the eOS dock theme switcher. Comment for vanilla. */' >> ~/.config/gtk-4.0/gtk.css
echo "@import \"$IMPORTFILE\";" >> ~/.config/gtk-4.0/gtk.css
fi
#killall io.elementary.dock
}
# Remove import in gtk config
# Remove file to leave no leftover
# dock restart
function disable_theme()
{
echo "removing import line in gtk.css."
# Cant seem to chain directly to itself
cat ~/.config/gtk-4.0/gtk.css \
| grep -v "@import \"$IMPORTFILE\";" \
| grep -v "/* Import line for the eOS dock theme switcher." \
> ~/.config/gtk-4.0/gtk1.css
# Use the temporary, then delete
cat ~/.config/gtk-4.0/gtk1.css > ~/.config/gtk-4.0/gtk.css
rm -f ~/.config/gtk-4.0/gtk1.css
rm -vf ~/.config/gtk-4.0/$IMPORTFILE
#killall io.elementary.dock
}
#========================
# EXECUTION =
#========================
if [[ -f "$*" ]] && [[ "$*" != "Default" ]] # Its a file and not "Default" (reserve Default, just in case)
then
echo "setting $*"
echo "/* CURRENT: $* */" > ~/.config/gtk-4.0/$IMPORTFILE
echo "" >> ~/.config/gtk-4.0/$IMPORTFILE
cat "$*" >> ~/.config/gtk-4.0/$IMPORTFILE
enable_theme
else
disable_theme
fi
echo "you may want to log anew or run killall io.elementary.dock to see the changes take effect"