This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
desktop-mode
279 lines (229 loc) · 6.98 KB
/
desktop-mode
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/env bash
# hai there ~ @nizarmah
args=("$@")
function setup() {
dmscript="$PWD/desktop-mode"
udmscript="/usr/bin/desktop-mode"
dmfiles="$PWD/.desktop-modes/"
udmfiles="/home/$SUDO_USER/.desktop-modes/"
shadow="$PWD/OSX-Arc-Shadow/"
ushadow="/usr/share/themes/OSX-Arc-Shadow/"
white="$PWD/OSX-Arc-White/"
uwhite="/usr/share/themes/OSX-Arc-White/"
papirus="$PWD/.desktop-modes/Papirus/"
upapirus="/usr/share/icons/Papirus/"
papirusdark="$PWD/.desktop-modes/Papirus-Dark/"
upapirusdark="/usr/share/icons/Papirus-Dark/"
apapirus=false
apapirusdark=false
if [ ! -f $udmscript ]; then
if [ -f $dmscript ]; then
mv $dmscript /usr/bin/
echo "Moved Desktop Mode script"
else
echo "Couldn't find Desktop Mode script"
fi
else
if [ -f $dmscript ]; then
rm -R $dmscript
fi
echo "Desktop Mode script already present"
fi
if [ ! -d $udmfiles ]; then
if [ -d $dmfiles ]; then
mv $dmfiles /home/$SUDO_USER/
echo "Moved Desktop Mode files"
else
echo "Couldn't find Desktop Mode files"
fi
else
if [ -d $dmfiles ]; then
rm -R $dmfiles
fi
echo "Desktop Mode files already present"
fi
if [ ! -d $ushadow ]; then
if [ -d $shadow ]; then
mv $shadow /usr/share/themes/
echo "Moved OSX-Arc-Shadow"
else
echo "Couldn't find OSX-Arc-Shadow"
fi
else
if [ -d $shadow ]; then
rm -R $shadow
fi
echo "OSX-Arc-Shadow already present"
fi
if [ ! -d $uwhite ]; then
if [ -d $white ]; then
mv $white /usr/share/themes/
echo "Moved OSX-Arc-White"
else
echo "Couldn't find OSX-Arc-White"
fi
else
if [ -d $white ]; then
rm -R $white
fi
echo "OSX-Arc-White already present"
fi
if [ ! -d $upapirus ]; then
apapirus=true
echo "Papirus is missing"
else
echo "Papirus already present"
fi
if [ ! -d $upapirusdark ]; then
apapirusdark=true
echo "Papirus-Dark is missing"
else
echo "Papirus-Dark already present"
fi
if [ $apapirus = true ] || [ $apapirusdark = true ]; then
read -p "Install the missing icons ? (y/n) " answer
if [ $answer = "y" ] || [ $answer = "Y" ] || [ $answer = "" ]; then
mkdir papirus
git clone https://github.com/PapirusDevelopmentTeam/papirus-icon-theme.git $PWD/papirus
if [ $apapirus = true ]; then
mv $PWD/papirus/Papirus/ /usr/share/icons/
echo "Installed Papirus"
fi
if [ $apapirusdark = true ]; then
mv $PWD/papirus/Papirus-Dark/ /usr/share/icons/
echo "Installed Papirus-Dark"
fi
rm -R $PWD/papirus
fi
fi
if [ ! -f "/usr/share/fonts/OTF/SanFranciscoDisplay-Regular.otf" ]; then
echo "San Francisco Display is missing"
read -p "Install the missing font ? (y/n) " answer
if [ $answer = "y" ] || [ $answer = "Y" ] || [ $answer = "" ]; then
mkdir sanfranfont
git clone https://github.com/AppleDesignResources/SanFranciscoFont.git $PWD/sanfranfont
mv $PWD/sanfranfont/* /usr/share/fonts/OTF/
echo "Installed San Francisco Display"
rm -R $PWD/sanfranfont
fi
else
echo "San Francisco Display already present"
fi
}
function uninstall() {
papirus=("Papirus" "Papirus-Dark")
arcs=("OSX-Arc-Shadow" "OSX-Arc-White")
sanfran=("SanFranciscoDisplay-Bold.otf" "SanFranciscoDisplay-Heavy.otf" "SanFranciscoDisplay-Light.otf" "SanFranciscoDisplay-Medium.otf" "SanFranciscoDisplay-Regular.otf" "SanFranciscoDisplay-Semibold.otf" "SanFranciscoDisplay-Thin.otf" "SanFranciscoDisplay-Ultralight.otf" "SanFranciscoText-Bold.otf" "SanFranciscoText-BoldItalic.otf" "SanFranciscoText-Heavy.otf" "SanFranciscoText-HeavyItalic.otf" "SanFranciscoText-Light.otf" "SanFranciscoText-LightItalic.otf" "SanFranciscoText-Medium.otf" "SanFranciscoText-MediumItalic.otf" "SanFranciscoText-Regular.otf" "SanFranciscoText-RegularItalic.otf" "SanFranciscoText-Semibold.otf" "SanFranciscoText-SemiboldItalic.otf")
dmscript="/usr/bin/desktop-mode"
dmfiles="/home/$SUDO_USER/.desktop-modes/"
ushadow="/usr/share/themes/OSX-Arc-Shadow/"
uwhite="/usr/share/themes/OSX-Arc-White/"
upapirus="/usr/share/icons/Papirus/"
upapirusdark="/usr/share/icons/Papirus-Dark/"
if [ ! -f "/usr/share/fonts/OTF/SanFranciscoDisplay-Regular.otf" ]; then
echo "San Francisco Display already uninstalled"
else
for i in "${!sanfran[@]}"; do
rm /usr/share/fonts/OTF/${sanfran[$i]}
if [ $((i+1)) -eq ${#sanfran[@]} ]; then
echo "Removed San Francisco Display"
fi
done
fi
if [ ! -d $upapirus ]; then
echo "Papirus is already uninstalled"
else
rm -rf /usr/share/icons/${papirus[0]}
echo "Removed ${papirus[0]}"
fi
if [ ! -d $upapirusdark ]; then
echo "Papirus-Dark is already uninstalled"
else
rm -rf /usr/share/icons/${papirus[1]}
echo "Removed ${papirus[1]}"
fi
if [ ! -d $ushadow ]; then
echo "OSX-Arc-Shadow is already uninstalled"
else
rm -rf /usr/share/themes/${arcs[0]}
echo "Removed ${arcs[0]}"
fi
if [ ! -d $uwhite ]; then
echo "OSX-Arc-White is already uninstalled"
else
rm -rf /usr/share/themes/${arcs[1]}
echo "Removed ${arcs[1]}"
fi
if [ ! -d dmfiles ]; then
echo "Desktop Mode files already uninstalled"
else
rm -rf $dmfiles
echo "Removed Desktop Mode files"
fi
if [ ! -f $dmscript ]; then
echo "Desktop Mode script already uninstalled"
else
rm $dmscript
echo "Removed Desktop Mode script"
fi
}
function setmode() {
cmode=$(</home/$USER/.desktop-modes/mode.txt)
tint2="/home/$USER/.config/tint2/tint2rc"
xfceterminal="/home/$USER/.config/xfce4/terminal/terminalrc"
if [ $1 = $cmode ]; then
echo "$1 already activated"
else
sed -i "s/$cmode/$1/g" /home/$USER/.desktop-modes/mode.txt
mode=()
case $1 in
day) mode+=("Papirus" "OSX-Arc-White");;
night) mode+=("Papirus-Dark" "OSX-Arc-Shadow")
esac
xfconf-query -c xsettings -p /Net/IconThemeName -s "${mode[0]}"
xfconf-query -c xsettings -p /Net/ThemeName -s "${mode[1]}"
xfconf-query -c xfwm4 -p /general/theme -s "${mode[1]}"
if [ -f $tint2 ]; then
cat "/home/$USER/.desktop-modes/tint2/$1-mode.tint2rc" > $tint2
killall -SIGUSR1 tint2
fi
if [ -f $xfceterminal ]; then
cat "/home/$USER/.desktop-modes/xfce4/$1-mode" > $xfceterminal
fi
echo "$1 mode activated"
fi
}
if [ ${#args[@]} -eq 1 ]; then
if [ ${args[0]} = "-h" ] || [ ${args[0]} = "--help" ]; then
echo "Help Options:"
echo " -h, --help Show help options"
echo ""
echo "Setup Options:"
echo " -S, --setup Setup required resources"
echo " -R, --remove Remove all required resources"
echo ""
echo "Desktop Modes:"
echo " -D, --day Enable day desktop mode"
echo " -N, --night Enable night desktop mode"
elif [ ${args[0]} = "-D" ] || [ ${args[0]} = "--day" ]; then
setmode "day"
elif [ ${args[0]} = "-N" ] || [ ${args[0]} = "--night" ]; then
setmode "night"
elif [ ${args[0]} = "-S" ] || [ ${args[0]} = "--setup" ]; then
if [ $USER = "root" ]; then
setup
else
echo "run this as root"
fi
elif [ ${args[0]} = "-R" ] || [ ${args[0]} = "--remove" ]; then
if [ $USER = "root" ]; then
uninstall
else
echo "run this as root"
fi
else
echo "command not found"
fi
else
echo "command not found"
fi