forked from benmooo/arch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx_install.sh
executable file
·161 lines (143 loc) · 5.21 KB
/
x_install.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
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
#!/bin/bash
USER_HOME=/home/$(whoami)
function configline() {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | sed 's/\//\\\//g')
touch "${FILE}"
sed -i '/'"${OLD_LINE_PATTERN}"'/{s/.*/'"${NEW}"'/;h};${x;/./{x;q100};x}' "${FILE}"
if [[ $? -ne 100 ]] && [[ ${NEW_LINE} != '' ]]
then
echo "${NEW_LINE}" >> "${FILE}"
fi
}
FUNC=$(declare -f configline)
# check prerequisites
function chk_prerequisites() {
# check network connection
ping -q -w1 -c1 baidu.com &> /dev/null
if [ $? -ne 0 ]; then
return 1
fi
# check if user is a sudo user
username=$(whoami)
getent group wheel | grep -q "\b${username}\b"
if [ $? -ne 0 ]; then
return 1
fi
}
# install pkgs
function install_pkgs() {
echo "##############################################"
echo "# Syncing aur..... "
echo "##############################################"
sudo pacman -Syy
# fonts
echo "##############################################"
echo "# Installing fonts... "
echo "##############################################"
sudo pacman -S ttf-roboto ttf-roboto-mono noto-fonts-cjk ttf-dejavu otf-font-awesome
# pkgs
echo "##############################################"
echo "# Installing packages.. "
echo "##############################################"
sudo pacman -S xorg-server xorg-xrandr lightdm lightdm-webkit2-greeter xmonad xmonad-contrib xmobar dmenu picom nitrogen termite rofi
}
function enable_lightdm() {
echo "##############################################"
echo "# Enable lightdm. "
echo "##############################################"
sudo systemctl enable lightdm
}
# set virtual machine resolution when booting lightdm
function set_resolution() {
# lightdm init script
echo "##############################################"
echo "# Set virtualbox resolution "
echo "##############################################"
sudo bash -c "$FUNC; configline '.*display-setup-script=' 'display-setup-script=xrandr --output VGA-1 --mode 1920x1080' /etc/lightdm/lightdm.conf"
}
# set greeter to webkit2
function set_greeter() {
echo "##############################################"
echo "# Set webkit2 as the greeter for lightdm.. "
echo "##############################################"
sudo bash -c "$FUNC; configline '.*greeter-session=.*' 'greeter-session=lightdm-webkit2-greeter' /etc/lightdm/lightdm.conf"
}
# download glorious theme
function download_glorious() {
# download lightdm theme
# curl -L -o ../glorious.tar.gz https://github.com/manilarome/lightdm-webkit2-theme-glorious/releases/download/v2.0.5/lightdm-webkit2-theme-glorious-2.0.5.tar.gz
scp [email protected]:/home/akatsuki/Downloads/lightdm* ../glorious.tar.gz
}
# customize lightdm
function set_greeter_theme() {
echo "###############################################################################"
echo "# Retriving glorious theme which is a webkit2-greeter theme for lightdm ... "
echo "###############################################################################"
echo ""
download_glorious
# extract
mkdir ../glorious
tar -C ../glorious -xzvf ../glorious.tar.gz
# move
sudo cp -r ../glorious /usr/share/lightdm-webkit/themes/glorious
# clean
rm -rf ../glorious ../glorious.tar.gz
echo "##############################################"
echo "# Set glorious as the theme of webkit2.... "
echo "##############################################"
sudo bash -c "$FUNC; configline '^webkit_theme.*' 'webkit_theme = glorious' /etc/lightdm/lightdm-webkit2-greeter.conf"
sudo bash -c "$FUNC; configline '^debug_mode.*' 'debug_mode = true' /etc/lightdm/lightdm-webkit2-greeter.conf"
}
function populate_dotfiles() {
echo "##############################################"
echo "# Populating configuation dotfiles... "
echo "##############################################"
cp -r ./migration/backups/dotfiles/.config $USER_HOME
cp -r ./migration/backups/dotfiles/.xmonad $USER_HOME
cp -r ./migration/backups/dotfiles/.face $USER_HOME
username=$(whoami)
sed -i -e "s/akatsuki/${username}/g" ../.xmonad/xmonad.hs
sed -i -e "s/akatsuki/${username}/g" ../.config/picom/picom.conf
}
function main() {
set -x
if [[ $1 == "chkPrerequisites" ]]
then
chk_prerequisites
elif [[ $1 == "installPkgs" ]]
then
install_pkgs
elif [[ $1 == "enableLightdm" ]]
then
enable_lightdm
elif [[ $1 == "setGreeter" ]]
then
set_greeter
elif [[ $1 == "populateDotfiles" ]]
then
populate_dotfiles
elif [[ $1 == "setResolution" ]]
then
set_resolution
elif [[ $1 == "setGreeterTheme" ]]
then
set_greeter_theme
elif [[ $1 == "all" ]]
then
chk_prerequisites
if [ $? -ne 0 ]; then
return 1
fi
install_pkgs
enable_lightdm
set_greeter
set_greeter_theme
set_resolution
populate_dotfiles
fi
{ set +x; } 2>/dev/null
}
main $1 $2 $3