-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjusAwesome.sh
executable file
·418 lines (367 loc) · 11.8 KB
/
jusAwesome.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
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
#!/bin/sh
# Author: Rushan Chen
# Email: [email protected]
appPath=$(pushd $(dirname $0) >/dev/null && pwd -P && popd >/dev/null)
# ======================================================================
# Util Functions
# ======================================================================
function Log()
{
echo $1 | tee -a log
}
function ExitFail()
{
echo $1
exit 1
}
function IsPkgExist()
{
local pkg=$1
pacman -Q $pkg 2> /dev/null > /dev/null
if [[ $? -eq 0 ]]; then
echo 1
else
echo 0
fi
}
function InstallPkg()
{
local pkgs=("${!1}")
for pkg in ${pkgs[@]}; do
local exist=`IsPkgExist $pkg`
if [[ $exist -eq 1 ]]; then
continue
fi
Log "Installing $pkg ..."
sudo pacman -S --noconfirm $pkg
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to install $pkg"
fi
done
}
function InstallPkgAUR()
{
local pkgUrl=$1
tgzName=${pkgUrl##*/}
pkgName=${tgzName%%.*}
exist=`IsPkgExist $pkgName`
if [[ $exist -eq 1 ]]; then
return
fi
Log "Installing $pkgName from AUR ..."
pkgs=(wget)
InstallPkg pkgs[@]
Log " * Downloading from AUR ..."
if [[ ! -e $tgzName ]]; then
wget $pkgUrl
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to download $tgzName"
fi
fi
Log " * Makepkging ..."
if [[ ! -e $pkgName ]]; then
tar zxvf $tgzName
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to extract $tgzName"
fi
fi
cd $pkgName
makepkg -sf
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to makepkg $pkgName"
fi
Log " * Installing ..."
pkg=`ls *.xz`
sudo pacman -U --noconfirm $pkg
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to install $pkgName"
fi
cd ..
rm -f $tgzName
rm -rf $pkgName
}
function InstallPkgAUR_Yaourt()
{
local pkgs=("${!1}")
for pkg in ${pkgs[@]}; do
local exist=`IsPkgExist $pkg`
if [[ $exist -eq 1 ]]; then
continue
fi
Log "Installing $pkg ..."
yaourt -S --noconfirm $pkg
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to install $pkg"
fi
done
}
function DownloadFileTo()
{
local url=$1
local dest=$2
if [[ -e $dest ]]; then
return
fi
pkgs=(wget)
InstallPkg pkgs[@]
sudo wget $url -O $dest
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to download $url to $dest"
fi
}
function DownloadFile()
{
local url=$1
DownloadFileTo $url "."
}
function InstallOpenboxTheme()
{
local themeName=$1
themeDir=$HOME/.themes
if [[ ! -e $themeDir ]]; then
mkdir $themeDir
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to create $themeDir"
fi
fi
if [[ ! -e $themeDir/$themeName ]]; then
Log "Installing theme $themeName ..."
tar zxvf conf/${themeName}.tgz
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to extract theme $themeName"
fi
mv $themeName $themeDir
fi
}
function DeleteSvnInfo()
{
local dir=$1
if [[ ! -d $dir ]]; then
return
fi
find $dir -type d -name '*svn*' -exec rm -rf {} \; 2> /dev/null > /dev/null
}
# ======================================================================
# Enviroment Construction Functions
# ======================================================================
function Awesome()
{
# install X server
pkgs=(xorg-server xorg-server-utils xorg-xinit)
InstallPkg pkgs[@]
# install awesome wm
pkgs=(awesome)
InstallPkg pkgs[@]
# install composite manager
pkgs=(compton-git)
InstallPkgAUR_Yaourt pkgs[@]
# install packages for gtk2, gtk3 theme
pkgs=(lxappearance gnome-themes-standard)
InstallPkg pkgs[@]
}
# Yaourt is a great tool for installing package from AUR
function Yaourt()
{
# dependency package
pkgs=(yajl)
InstallPkg pkgs[@]
# dependency package
pkg='https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz'
InstallPkgAUR $pkg
pkg='https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz'
InstallPkgAUR $pkg
}
function Fonts()
{
# all the following fonts are necessary in order for all applications
# to display font (including Chinese font) properly.
# dejavu (a useful font)
fonts=(ttf-dejavu terminus-font)
InstallPkg fonts[@]
# Chinese fonts
fonts=(ttf-arphic-uming ttf-arphic-ukai opendesktop-fonts)
InstallPkg fonts[@]
fonts=(
monaco-linux-font
ttf-ms-fonts # to solve firefox font rendering problem on certain pages like Google
ttf-vista-fonts # including consolas
)
InstallPkgAUR_Yaourt fonts[@]
xset +fp /usr/share/fonts/local
xset fp rehash
}
function NetworkManager()
{
pkgs=(networkmanager networkmanager-openconnect gnome-keyring network-manager-applet xfce4-notifyd)
InstallPkg pkgs[@]
sudo systemctl enable NetworkManager.service
sudo systemctl start NetworkManager.service
}
# This app can convert latex functions to SVG format
function Inkscape()
{
pkgs=(inkscape textlive-core textlive-bin pstoedit dvips ghostscript)
InstallPkg pkgs[@]
}
function Apps()
{
apps=(
xorg-xbacklight # used to ajust the brightness of backlight
rxvt-unicode
xsel # copy & paste on command line
feh # image viewerh
vim # editor
tint2 # a great panel with great document
tmux # a replacement of screen
sunpinyin # replacement of scim and scim-pinyin
sunpinyin-data
flashplugin
subversion
xorg-xprop # get window property by clicking on it
wmctrl # enables you to control your WM from command line
mplayer # video player
alsa-utils # used to ajust the master volume
xorg-xev # to capture the event generated by keyboard and mouse
jre7-openjdk # java runtime env which I choose to use the open source version
unrar
openssh
openconnect # cisco vpn client
youtube-dl # youtube video downloader
bash-completion # smart bash completion
apvlv # lightweight vim-like pdf viewer
virtualbox # virtual machine
virtualbox-host-modules
qt4
pidgin # for google talk
imagemagick # contain "import" command which is used to take screenshot
gphoto2 # to copy image from iphone
icedtea-web # java support for web browser
gdb # debugger
valgrind # debugger
clang # for auto-complete
gpick # color picker
mpd # music player daemon
mpc # music player client
xlockmore # screen locker
lm_sensors
arandr # frontend of xrandr which is for multiple screen display
evince # pdf reader
cmake
fcitx # input method
fcitx-googlepinyin
fcitx-libpinyin
unzip
)
InstallPkg apps[@]
aur_apps=(
# xseticon # xseticon enables you to set icon for an app at runtime
equalx # to write equation
# dropbox-experimental # file sharing service
# kompozer # Kompozer is for WYSIWYG html editing
grabc # command line tool to get pixel color on screen
vim-clang-complete-git # for auto-complete
zukitwo-themes # many gtk2 and gtk3 themes
google-chrome # replacement of firefox
sogou
)
InstallPkgAUR_Yaourt aur_apps[@]
Log "=================================================="
Log "Link /usr/bin/python to /usr/bin/python3"
Log "=================================================="
# sudo ln -s /usr/bin/python3 /usr/bin/python
# if [[ $? -ne 0 ]]; then
# ExitFail "[ERROR]: fail to link /usr/bin/python"
# fi
}
function Goagent()
{
# goagent is important for svn and web-browsing
# NOTE that the gevent package should be 1.0dev (or 1.0rc) at the moment
# which is same as what comes with Windows and Mac
pkgs=(python2 python2-gevent-beta python2-pyopenssl)
InstallPkg pkgs[@]
if [[ -e /usr/bin/python ]]; then
Log "=================================================="
Log "REMOVE soft link /usr/bin/python"
Log "=================================================="
sudo rm /usr/bin/python
fi
# initialize for goagent, this may be needed in some situations
local dir=$HOME/.pki/nssdb/
if [[ ! -e $dir ]]; then
mkdir -p $dir
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to create $dir"
fi
echo "[*] just input empty password below"
certutil -d $dir -N
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to run certutil"
fi
fi
}
function LinkConf()
{
rm /home/juscodit/.bashrc
ln -s /home/juscodit/jusAwesome/conf/.Xdefaults /home/juscodit/.Xdefaults
ln -s /home/juscodit/jusAwesome/conf/.bashrc /home/juscodit/.bashrc
ln -s /home/juscodit/jusAwesome/conf/.vim/ /home/juscodit/.vim
ln -s /home/juscodit/jusAwesome/conf/.vimrc /home/juscodit/.vimrc
ln -s /home/juscodit/jusAwesome/conf/.terminfo/ /home/juscodit/.terminfo/
ln -s /home/juscodit/jusAwesome/conf/.compton.conf /home/juscodit/.compton.conf
ln -s /home/juscodit/jusAwesome/conf/.config/awesome/ /home/juscodit/.config/awesome/
ln -s /home/juscodit/jusAwesome/conf/.fonts/ /home/juscodit/.fonts/
ln -s /home/juscodit/jusAwesome/conf/.tmux.conf /home/juscodit/.tmux.conf
}
function TODO()
{
Log "=================================================="
Log "TODO:"
Log "[*] Change gtk them with lxappearance"
Log "[*] run sensors-detect"
Log "[*] change the wireless interface in .conkyrc"
Log "[*] change your qt app appearance with qtconfig-qt4, it has option to"
Log " utilize the GTK theme"
Log "[*] goagent is in repository. You may need to enable community-test in"
Log " /etc/pacman.conf to install the newest version. Note that you'd"
Log " better cp goagent from /usr/share/ to your home directory, goagent"
Log " would create file under its dir at runtime, and it reqiures root"
Log " permission if you run it from /usr/share/. So copy to your home and"
Log " run it there, it will save you from running as sudo."
Log "[*] add CA.crt of goagent to global certificate db as: (or youtube-dl won't work)"
Log " # mkdir /usr/local/share/ca-certificates/"
Log " # cp /usr/share/goagent/local/CA.crt /usr/local/share/ca-certificates/"
Log " # update-ca-certificates"
Log "[*] add vboxdrv to /etc/modules-load.d/vboxdrv.conf"
Log "[*] add snd-pcm-oss to /etc/modules-load.d/snd.conf so that conky can"
Log " display sound volume"
Log "[*] install AutoHotkey in vbox windows and make it start at boot"
Log '[*] put conf/AutoHotkey.ahk in windows'
Log ' C:\Documents and Settings\Administrator\My Documents'
Log "[*] see manual section of https://wiki.archlinux.org/index.php/OpenConnect"
Log " to setup openconnect"
Log "[*] run hwclock -s --localtime if your time is not correct"
Log "[*] Note that the cpuid argument to the '\${cpu}' object of .conkyrc"
Log " refers to the virtual processor, not the pysical core of your cpu."
Log " Check /proc/cpuinfo, if you see 'ht' in flags, then your cpu has"
Log " hyperthreading enabled which means you'll have multiple virtual"
Log " processor in each pysical core, and you should modify .conkyrc"
Log " accordingly to display the right cpu usage."
Log "[*] run tic for terminfo"
Log "=================================================="
}
function CreateOpenboxEnv()
{
sudo pacman -Sy
if [[ $? -ne 0 ]]; then
ExitFail "[ERROR]: fail to update package database"
fi
Yaourt
Awesome
Fonts
NetworkManager
Apps
LinkConf
TODO
}
CreateOpenboxEnv