-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamic-Panel-Transparency
111 lines (107 loc) · 5.01 KB
/
Dynamic-Panel-Transparency
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
# Requires: xprop
##################################
# Adjust values to suit
PANEL=top
PANEL_ALPHA_REGULAR=0.65
PANEL_ALPHA_MAXIMUM=0.90
##################################
##################################
# don't change anything below here
##################################
# Change background type to color
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/top/background/ type "color"
CURR=0
while true
do
# if theme carrier file doesn't exist create it
if [ ! -f "$HOME/.local/bin/thm-crr.txt" ]; then
touch "$HOME"/.local/bin/thm-crr.txt
echo "theme:........." > "$HOME"/.local/bin/thm-crr.txt
fi
# get current theme and compare against theme carrier
ThemeName=$(gsettings get org.mate.Marco.general theme|cut -f2 -d"'")
ThemeCarrier=$(grep -i 'theme:' "$HOME"/.local/bin/thm-crr.txt|cut -f2 -d":")
if [ "$ThemeName" != "$ThemeCarrier" ]; then
# write theme name to theme carrier
echo "theme:$ThemeName" > "$HOME"/.local/bin/thm-crr.txt
# retrieve theme bg color and write to theme carrier
if [ -d "/usr/share/themes/$ThemeName" ]; then
if [ -f "/usr/share/themes/$ThemeName/gtk-3.0/gtk-main.css" ]; then
CRc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 2-3|head --bytes 2)
CRc=$(echo $CRc | tr '[:lower:]' '[:upper:]')
CR=$(echo "ibase=16; $CRc"|bc)
CGc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 4-5|head --bytes 2)
CGc=$(echo $CGc | tr '[:lower:]' '[:upper:]')
CG=$(echo "ibase=16; $CGc"|bc)
CBc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 6-7|head --bytes 2)
CBc=$(echo $CBc | tr '[:lower:]' '[:upper:]')
CB=$(echo "ibase=16; $CBc"|bc)
echo "color:$CR,$CG,$CB" >> "$HOME"/.local/bin/thm-crr.txt
else
CRc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 2-3|head --bytes 2)
CRc=$(echo $CRc | tr '[:lower:]' '[:upper:]')
CR=$(echo "ibase=16; $CRc"|bc)
CGc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 4-5|head --bytes 2)
CGc=$(echo $CGc | tr '[:lower:]' '[:upper:]')
CG=$(echo "ibase=16; $CGc"|bc)
CBc=$(grep -i 'bg_color' /usr/share/themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 6-7|head --bytes 2)
CBc=$(echo $CBc | tr '[:lower:]' '[:upper:]')
CB=$(echo "ibase=16; $CBc"|bc)
echo "color:$CR,$CG,$CB" >> "$HOME"/.local/bin/thm-crr.txt
fi
else
if [ -f "$HOME/.themes/$ThemeName/gtk-3.0/gtk-main.css" ]; then
CRc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 2-3|head --bytes 2)
CRc=$(echo $CRc | tr '[:lower:]' '[:upper:]')
CR=$(echo "ibase=16; $CRc"|bc)
CGc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 4-5|head --bytes 2)
CGc=$(echo $CGc | tr '[:lower:]' '[:upper:]')
CG=$(echo "ibase=16; $CGc"|bc)
CBc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk-main.css|cut -f3 -d" "|cut -c 6-7|head --bytes 2)
CBc=$(echo $CBc | tr '[:lower:]' '[:upper:]')
CB=$(echo "ibase=16; $CBc"|bc)
echo "color:$CR,$CG,$CB" >> "$HOME"/.local/bin/thm-crr.txt
else
CRc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 2-3|head --bytes 2)
CRc=$(echo $CRc | tr '[:lower:]' '[:upper:]')
CR=$(echo "ibase=16; $CRc"|bc)
CGc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 4-5|head --bytes 2)
CGc=$(echo $CGc | tr '[:lower:]' '[:upper:]')
CG=$(echo "ibase=16; $CGc"|bc)
CBc=$(grep -i 'bg_color' "$HOME"/.themes/"$ThemeName"/gtk-3.0/gtk.css|cut -f3 -d" "|cut -c 6-7|head --bytes 2)
CBc=$(echo $CBc | tr '[:lower:]' '[:upper:]')
CB=$(echo "ibase=16; $CBc"|bc)
echo "color:$CR,$CG,$CB" >> "$HOME"/.local/bin/thm-crr.txt
fi
fi
fi
# get theme bg color from theme carrier
Clrcrr=$(grep -i 'color:' "$HOME"/.local/bin/thm-crr.txt|cut -f2 -d":")
MAX_FND=0
for w in $(xprop -notype -root _NET_CLIENT_LIST 2>/dev/null | cut -d'#' -f2 | tr ',' '\n' | awk '{print $1}')
do
if [ "$(xprop -id "$w" -notype _NET_WM_DESKTOP 2>/dev/null | cut -d' ' -f3)" -eq "$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null | cut -d' ' -f3)" ]
then
if xprop -id "$w" _NET_WM_STATE | grep -E "MAXIMIZED_HORZ.*MAXIMIZED_VERT|MAXIMIZED_VERT.*MAXIMIZED_HORZ" > /dev/null 2>&1
then
if xprop -id "$w" WM_STATE | grep -E "window state: Normal" > /dev/null 2>&1
then
MAX_FND=1
break
fi
fi
fi
done
if [ $MAX_FND -eq 1 ] && [ $CURR -eq 0 ]
then
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/${PANEL}/background/ color "rgba($Clrcrr,$PANEL_ALPHA_MAXIMUM)"
CURR=1
elif [ $MAX_FND -eq 0 ] && [ $CURR -eq 1 ]
then
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/${PANEL}/background/ color "rgba($Clrcrr,$PANEL_ALPHA_REGULAR)"
CURR=0
fi
sleep 2
done
Exit 0