-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.0-Install-Desktop-Environment.bash
491 lines (384 loc) · 13.8 KB
/
2.0-Install-Desktop-Environment.bash
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#!/bin/bash
##
## 2.0-Install-Desktop-Environment.sh
##
function Decorative_Formatting {
## Decorative tty colors
function Tput_Colors {
## Foreground Color using ANSI escape provided through tput
FG_BLACK=$(tput setaf 0)
FG_RED=$(tput setaf 1)
FG_GREEN=$(tput setaf 2)
FG_YELLOW=$(tput setaf 3)
FG_BLUE=$(tput setaf 4)
FG_MAGENTA=$(tput setaf 5)
FG_CYAN=$(tput setaf 6)
FG_WHITE=$(tput setaf 7)
FG_NoColor=$(tput sgr0)
## Background Color using ANSI escape provided through tput
BG_BLACK=$(tput setab 0)
BG_RED=$(tput setab 1)
BG_GREEN=$(tput setab 2)
BG_YELLOW=$(tput setab 3)
BG_BLUE=$(tput setab 4)
BG_MAGENTA=$(tput setab 5)
BG_CYAN=$(tput setab 6)
BG_WHITE=$(tput setab 7)
BG_NoColor=$(tput sgr0)
## set mode using ANSI escape provided through tput
MODE_BOLD=$(tput bold)
MODE_DIM=$(tput dim)
MODE_BEGIN_UNDERLINE=$(tput smul)
MODE_EXIT_UNDERLINE=$(tput rmul)
MODE_REVERSE=$(tput rev)
MODE_ENTER_STANDOUT=$(tput smso)
MODE_EXIT_STANDOUT=$(tput rmso)
# clear styles using ANSI escape provided through tput
STYLES_OFF=$(tput sgr0)
FGBG_NoColor=$(tput sgr0)
}
function ttyCenter {
str="$1"
tputFgColor=$2
width=$( tput cols )
if [ $width -gt 80 ]; then width=80; fi
strLength=${#str}
centerCol=$(( ( width/2 )-( strLength / 2 ) ))
for (( i=0; i<=$centerCol; i++ ))
do
printf " "
done
printf "$MODE_BOLD$tputFgColor$str$STYLES_OFF\n"
}
function ttyHR {
hrChar=$1
tputFgColor=$2
width=$( tput cols )
if [ $width -gt 80 ]; then width=80; fi
for (( i=0; i<$width; i++ ))
do
printf "$tputFgColor$hrChar"
done
printf "$STYLES_OFF\n"
}
function ttyNestedString {
str=$1
tputFgColor=$2
strArray=($str)
lineArray=()
strLength="${#str}"
preString=" "
ttyMaxCols=$( tput cols )
if [ $ttyMaxCols -gt 80 ]; then ttyMaxCols=80; fi
ttyMaxCols=$(($ttyMaxCols-1))
charCount=0
isFrstLine=1
printf "$tputFgColor"
for i in "${strArray[@]}"; do
charCount=$(($charCount+${#i}+1))
if [ $isFrstLine -ne 1 ]; then
ttyMaxCols=$( tput cols )
if [ $ttyMaxCols -gt 80 ]; then ttyMaxCols=80; fi
ttyMaxCols=$(($ttyMaxCols-5))
preString=" "
else
preString=" "
fi
if [ $charCount -lt $ttyMaxCols ]; then
## append lineArray
lineArray+=("$i")
else
echo "$preString${lineArray[*]}"
isFrstLine=0
lineArray=()
lineArray+=("$i")
charCount=${#i}
fi
done
if [ $isFrstLine -ne 1 ]; then
preString=" "
else
preString=" "
fi
printf "$preString${lineArray[*]}\n$STYLES_OFF"
}
function ttyCenteredHeader {
str=$1
borderChar=$2
tputFgColor=$3
ttyHR "$borderChar" "$tputFgColor"
ttyCenter "$str" "$tputFgColor"
ttyHR "$borderChar" "$tputFgColor"
}
function ttyHighlightRow {
str=$1
tputBgColor=$2
width=$( tput cols )
if [ $width -gt 80 ]; then width=80; fi
width=$(($width - 3))
strLength=${#str}
highlightLength=$(( $width-$strLength ))
printf "$tputBgColor$FG_BLACK= $str "
for (( i=0; i<$highlightLength; i++ ))
do
printf "$tputBgColor="
done
printf "$STYLES_OFF\n"
}
function ttyPromptInput {
promptTitle=$1
promptString=$2
defaultAnswer=$3
tputFgColor=$4
tputBgColor=$5
ttyHighlightRow "$promptTitle" "$tputBgColor"
case $defaultAnswer in
[Nn]* )
readWait='-t 10'
;;
* )
readWait=""
;;
esac
echo ""
ttyNestedString "(wait time < 10sec) '$defaultAnswer' will automatically be input ..." "$FG_NoColor"
read $readWait -e -p " $tputFgColor$promptString$STYLES_OFF" -i "$defaultAnswer" readInput
if [ $? -ne 0 ]; then echo ""; fi
printf "$STYLES_OFF\n"
sleep 1
}
}
function Configure_Desktop_Environment {
function Install_DWM {
ttyCenteredHeader "Compile Suckless Environment" "░" "$FG_CYAN"
sleep 2s
## variable used to cd back to the directory
thisScriptPath=$(pwd)
ttyCenteredHeader "Installing Simple Terminal (st)" "+" "$FG_MAGENTA"
sleep 2s && cd ~/suckless/st
sudo make clean install && cd ~/suckless/dmenu
ttyCenteredHeader "Installing Dmenu" "+" "$FG_MAGENTA"
sleep 2s && cd ~/suckless/dwm
sudo make clean install && cd ~/suckless/dwm
ttyCenteredHeader "Installing Dynamic Window Manager (dwm)" "+" "$FG_MAGENTA"
sleep 2s && cd ~/suckless/dwm
sudo make clean install && cd $thisScriptPath
sleep 5s
}
function Suckless_Patches {
ttyCenteredHeader "Installing Suckless dependencies" "-" "$FG_CYAN"
sleep 2s
sudo apt update
sudo apt --fix-broken install
sudo apt update
sudo apt install -y build-essential
sudo apt install -y git
## If Not WLS
if [ $(uname -r | grep Microsoft &> /dev/null; echo $?) -ne 0 ]; then
sudo apt install -y xorg
sudo apt install -y xinit
sudo apt install -y arandr
fi
## dwm requirements
sudo apt install -y libx11-dev
sudo apt install -y libxft-dev
sudo apt install -y libxinerama-dev
sudo apt install -y xclip
sudo apt install -y xvkbd
sudo apt install -y libgcr-3-dev
sudo apt install -y suckless-tools
ttyCenteredHeader "Importing DE Patches" "+" "$FG_CYAN"
sleep 2s
ttyNestedString "Importing ~/suckless ..." "$MODE_BOLD$FG_GREEN"
sleep 1s
sudo cp -rf --no-preserve=mode ./suckless ~/
sleep 2s
sudo chmod -R 777 ~/suckless/*
#sudo cp -rf --no-preserve=mode ./home/terminalsexy ~/
## Original DWM Source
#git clone git://git.suckless.org/dwm ~/suckless/factory-default/dwm
#git clone git://git.suckless.org/st ~/suckless/factory-default/st
#git clone https://git.suckless.org/slstatus ~/suckless/factory-default/slstatus
ttyNestedString "Writing ~/.fehbg ..." "$MODE_BOLD$FG_GREEN"
sleep 1s
echo -e "feh --bg-fill ~/.config/openbox/wcrr.png \n" > ~/.fehbg
sleep 1s
if [ -f ~/.xinitrc ]; then
ttyNestedString "Backing up ~/.xinitrc ..." "$MODE_DIM$FG_YELLOW"
sleep 1s
cp ~/.xinitrc ~/.xinitrc.backup.$(date +%d%b%Y_%H%M%S)
sleep 1s
fi
## xinit
ttyNestedString "Writing ~/.xinitrc ..." "$MODE_BOLD$FG_GREEN"
echo -e "xsetroot -name \" headless-host ▷ \$(whoami) \"\n" > ~/.xinitrc
echo -e "bash ~/.fehbg &" >> ~/.xinitrc
echo -e "xrdb ~/.Xresources &\n" >> ~/.xinitrc
echo -e "command -v dwm &>/dev/null" >> ~/.xinitrc
echo -e "isDWM=$?\n" >> ~/.xinitrc
echo -e "command -v dwm &>/dev/null" >> ~/.xinitrc
echo -e "isOpenbox=\$?\n" >> ~/.xinitrc
echo -e "if [ \$isDWM -eq 0 ]; then" >> ~/.xinitrc
echo -e "\tif [ -f ~/suckless/dwm/dwm ]; then" >> ~/.xinitrc
echo -e "\t\texec ~/suckless/dwm/dwm" >> ~/.xinitrc
echo -e "\telse" >> ~/.xinitrc
echo -e "\t\texec dwm" >> ~/.xinitrc
echo -e "\tfi" >> ~/.xinitrc
echo -e "elif [ \$isOpenbox -eq 0 ]; then" >> ~/.xinitrc
echo -e "\texec openbox-session" >> ~/.xinitrc
echo -e "fi" >> ~/.xinitrc
sleep 2s
}
function Optional_Openbox {
ttyCenteredHeader "Installing Openbox" "+" "$FG_CYAN"
sleep 2s
sudo apt install -y openbox
sudo apt install -y tint2
sudo apt install -y conky
}
function Desktop_Applications {
ttyCenteredHeader "Installing gtk and other desktop environment tools" "+" "$FG_CYAN"
sleep 2s
## Xorg DE apps
sudo apt update
sudo apt --fix-broken install
sudo apt update
sudo apt install -y build-essential
sudo apt install -y libvte-dev
sudo apt install -y geany
sudo apt install -y geany-plugins
sudo apt install -y mousepad
sudo apt install -y zathura
sudo apt install -y mupdf
sudo apt install -y pcmanfm
sudo apt install -y libfm-tools
sudo apt install -y libusbmuxd-tools
sudo apt install -y udiskie
sudo apt install -y xarchiver
sudo apt install -y gvfs
sudo apt install -y tumbler
sudo apt install -y ffmpegthumbnailer
## Openbox backup
sudo apt install -y xterm
sudo apt install -y openbox
sudo apt install -y tint2
sudo apt install -y conky
sudo apt install -y feh
sudo apt install -y gparted
## light weight screensaver
# sudo apt install xfishtank
sudo apt install -y iceweasel
sudo apt install -y firefox-esr
sudo apt install -y gimp
}
function Clean_Apt_Cache {
sudo apt clean
sudo rm -rvf /var/cache/apt/archives/*.deb
}
function Home_Directory {
## Home Directory Configs
## This function assumes the script is running as source when launched from the headless-host root directory.
ttyCenteredHeader "Dot Files (Desktop Environment)" "+" "$FG_CYAN"
ttyNestedString "Populating home Directory Configs and dot files..." "$FG_YELLOW"
sleep 2s
if [ -d ./home/.config ]; then
ttyNestedString "Importing ~/.config ..." "$MODE_BOLD$FG_GREEN"
sleep 1s
sudo cp -rf --no-preserve=mode ./home/.config ~/
sudo chmod -R 777 ~/.config/*
fi
if [ -f ~/.bashrc ]; then
if [ -f ~/terminalsexy/Xresources/myNord.light ]; then
ttyNestedString "Applying a light nord theme to ~/.Xresources ..." "$MODE_BOLD$FG_GREEN"
## Light Xterm theme
cp ~/terminalsexy/Xresources/myNord.light ~/.Xresources
echo '' >> ~/.bashrc
echo '## xterm color scheme ' >> ~/.bashrc
echo 'pgrep -x Xorg &>/dev/null ' >> ~/.bashrc
echo 'isXorg=$?' >> ~/.bashrc
echo 'if [ $isXorg -eq 0 ]; then' >> ~/.bashrc
echo -e "\txrdb -merge ~/.Xresources" >> ~/.bashrc
echo 'fi' >> ~/.bashrc
echo '' >> ~/.bashrc
fi
fi
mkdir -p ~/Downloads
## Vim cache
mkdir -p ~/.backup/
mkdir -p ~/.swp/
mkdir -p ~/.undo/
sleep 1
}
function Desktop_Audio {
ttyCenteredHeader "Desktop Audio" "-" "$FG_CYAN"
#sudo dpkg-query --list alsa-utils pavucontrol vlc libdvd-pkg libdvd-pkg
command -v pulseaudio &>/dev/null
isPulse=$?
command -v alsamixer &>/dev/null
isAlsa=$?
command -v vlc &>/dev/null
isVlc=$?
if [ $isPulse -ne 0 ]; then
promptString="Install VLC Media Player and its dependencies? [ Y/n ]: "
readInput=yes
elif [ $isAlsa -ne 0 ]; then
promptString="Install VLC Media Player and its dependencies? [ Y/n ]: "
readInput=yes
elif [ $isVlc -ne 0 ]; then
promptString="Install VLC Media Player and its dependencies? [ Y/n ]: "
readInput=yes
else
promptString="Install VLC Media Player and its dependencies? [ y/N ]: "
readInput=no
fi
ttyPromptInput "VLC:" "$promptString" "$readInput" "$FG_GREEN" "$BG_GREEN"
case $readInput in
[Yy]* )
thisKernel=$(uname -r)
echo $thisKernel | grep Microsoft &>/dev/null
isMS=$?
if [ $isMS -ne 0 ]; then
## Debian 10.5 live iso comes with audio driver stuff. Or maybe it is just bundled in the package now.
sudo apt install -y alsa-utils
sudo apt install -y pavucontrol
#sudo apt install -y mplayer
sudo apt install -y vlc
## play protected dvd movies
sudo apt install -y libdvd-pkg
sudo dpkg-reconfigure libdvd-pkg
fi
sleep 2s
;;
esac
}
}
## #############################################################################
## Configure Desktop Environment
## #############################################################################
## Initialize
Decorative_Formatting
Tput_Colors
Configure_Desktop_Environment
clear
ttyCenteredHeader "Desktop Environment" "░" "$FG_MAGENTA"
sleep 2s
## RUN
uname -v | grep "Debian" --color
isDebian=$?
if [ $isDebian -eq 0 ]; then
Desktop_Applications
Optional_Openbox
Desktop_Audio
## DWM
Suckless_Patches
Install_DWM
Home_Directory
Clean_Apt_Cache
else
## Cancel
echo ""
ttyCenteredHeader "Canceling Installation/Configuration" "░" "$FG_YELLOW"
ttyNestedString "This script was intended for dedicated Debian linux server machines. This script makes assumptions appropriate for systems which installed the debian-live-10.x.x-amd64-standard.iso" "$FG_YELLOW"
echo ""
read -p "[Press ENTER to continue ...]" pauseEnter
fi