1 | #!/bin/bash |
2 |
|
3 | HELPTEXT="./install.sh <desktop|laptop|headless>" |
4 | case $1 in |
5 | h|help|\?|-h|-help|-\?|--h|--help|--\?) |
6 | echo -e $HELPTEXT |
7 | exit 0 |
8 | ;; |
9 | desktop) |
10 | UNIT=DESKTOP |
11 | ;; |
12 | laptop) |
13 | UNIT=LAPTOP |
14 | ;; |
15 | headless) |
16 | UNIT=HEADLESS |
17 | ;; |
18 | *) |
19 | echo -e $HELPTEXT |
20 | exit 0 |
21 | ;; |
22 | esac |
23 |
|
24 | category(){ |
25 | echo -e " \e[1;37m$1\e[0m" |
26 | } |
27 |
|
28 | item(){ |
29 | echo -e " \e[0m$1\e[0m" |
30 | } |
31 |
|
32 | echo -e " \e[1;33mInstall type \e[1;35m$UNIT\e[0m" |
33 |
|
34 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" |
35 |
|
36 | # Bash config |
37 | category "Bash config" |
38 | item "~/.bash_aliases" |
39 | install $SCRIPT_DIR/.bash_aliases $HOME/.bash_aliases |
40 | item "~/.bashrc" |
41 | install $SCRIPT_DIR/.bashrc $HOME/.bashrc |
42 | item "~/.profile" |
43 | install $SCRIPT_DIR/.profile $HOME/.profile |
44 |
|
45 | # Misc config |
46 | category "Misc config" |
47 | item "~/.todo.cfg" |
48 | install $SCRIPT_DIR/.todo.cfg $HOME/.todo.cfg |
49 | if [ $UNIT == "LAPTOP" ]; then |
50 | item "~/.xsessionrc" |
51 | install $SCRIPT_DIR/.xsessionrc $HOME/.xsessionrc |
52 | fi |
53 |
|
54 | category "Common folders" |
55 | item "~/src/" |
56 | SRCFOLDER=$HOME/src |
57 | mkdir -p $SRCFOLDER |
58 | item "~/.local/bin/" |
59 | LOCALBIN=$HOME/.local/bin |
60 | mkdir -p $LOCALBIN |
61 | item "~/.local/share/" |
62 | mkdir -p $HOME/.local/share |
63 |
|
64 | # Local scripts |
65 | category "Local scripts" |
66 | if [ $UNIT == "DESKTOP" ] && [ $(whoami) != "root" ]; then |
67 | item "~/.local/bin/middle-mouse-scroll" |
68 | install $SCRIPT_DIR/middle-mouse-scroll $LOCALBIN/middle-mouse-scroll |
69 | fi |
70 |
|
71 | if ! command -v minesweeper &> /dev/null |
72 | then |
73 | if [ $(whoami) == "root" ]; then |
74 | item "/usr/local/bin/minesweeper" |
75 | else |
76 | item "~/.local/bin/minesweeper" |
77 | fi |
78 | git clone --depth=1 git://joshstock.in/ncurses-minesweeper.git $SRCFOLDER/ncurses-minesweeper |
79 | cd $SRCFOLDER/ncurses-minesweeper |
80 | make compile build |
81 | if [ $(whoami) == "root" ]; then |
82 | install bin/minesweeper /usr/local/bin/minesweeper |
83 | else |
84 | install bin/minesweeper $LOCALBIN/minesweeper |
85 | fi |
86 | rm -rf $SRCFOLDER/ncurses-minesweeper |
87 | cd $SCRIPT_DIR |
88 | fi |
89 |
|
90 | if [ $UNIT == "DESKTOP" ] || [ $UNIT == "LAPTOP" ]; then |
91 | # GTK config |
92 | category "GTK config" |
93 |
|
94 | GTKDIR=$HOME/.config/gtk-3.0 |
95 | item "~/.config/gtk-3.0/" |
96 | mkdir -p $GTKDIR |
97 |
|
98 | item "~/.config/gtk-3.0/gtk.css" |
99 | install $SCRIPT_DIR/gtk.css $GTKDIR/gtk.css |
100 |
|
101 | item "Terminal theme 'Oceanic Next'" |
102 | $SCRIPT_DIR/terminal_theme.sh $1 &>/dev/null |
103 |
|
104 | if [ $(whoami) == "root" ]; then |
105 | # Fonts |
106 | category "Fonts" |
107 | FONTDIR=/usr/share/fonts |
108 |
|
109 | item "Fira Sans pack" |
110 | if [ ! -f $FONTDIR/FiraSans-Regular.ttf ]; then |
111 | curl -fLso /tmp/Fira.zip https://fonts.google.com/download?family=Fira%20Sans |
112 | unzip -q /tmp/Fira.zip -d $FONTDIR |
113 | fi |
114 |
|
115 | item "Fira Mono (Nerd Fonts) pack" |
116 | if [ ! -f $FONTDIR/FiraMono-Regular.otf ]; then |
117 | curl -fLso $FONTDIR/FiraMono-Regular.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Regular/complete/Fura%20Mono%20Regular%20Nerd%20Font%20Complete%20Mono.otf |
118 | fi |
119 | if [ ! -f $FONTDIR/FiraMono-Medium.otf ]; then |
120 | curl -fLso $FONTDIR/FiraMono-Medium.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Medium/complete/Fura%20Mono%20Medium%20Nerd%20Font%20Complete%20Mono.otf |
121 | fi |
122 | if [ ! -f $FONTDIR/FiraMono-Bold.otf ]; then |
123 | curl -fLso $FONTDIR/FiraMono-Bold.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Bold/complete/Fura%20Mono%20Bold%20Nerd%20Font%20Complete%20Mono.otf |
124 | fi |
125 |
|
126 | item "Refreshing font cache" |
127 | fc-cache |
128 | fi |
129 | fi |
130 |
|
131 | # Global git config |
132 | category "Global git config" |
133 |
|
134 | if [ $(whoami) == "root" ]; then |
135 | item "/etc/gitconfig" |
136 | install $SCRIPT_DIR/.gitconfig /etc/gitconfig |
137 | else |
138 | item "~/.gitconfig" |
139 | install $SCRIPT_DIR/.gitconfig $HOME/.gitconfig |
140 | fi |
141 |
|
142 | # Vim |
143 | category "Vim config" |
144 |
|
145 | if [ $UNIT == "HEADLESS" ]; then |
146 | if [ $(whoami) == "root" ]; then |
147 | item "/usr/share/vim/" |
148 | VIMDIR=/usr/share/vim |
149 | mkdir -p $VIMDIR |
150 | item "/usr/share/vim/vimrc" |
151 | grep -v "RMHEADLESS" vimrc > $SCRIPT_DIR/.vimrc_headless |
152 | install $SCRIPT_DIR/.vimrc_headless $VIMDIR/vimrc |
153 | VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' ` |
154 | item "$VIMRUNTIME/autoload/plug.vim" |
155 | if [ ! -f $VIMRUNTIME/autoload/plug.vim ]; then |
156 | curl -fLso $VIMRUNTIME/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
157 | fi |
158 | fi |
159 | else |
160 | item "~/.vim/" |
161 | VIMDIR=$HOME/.vim |
162 | mkdir -p $VIMDIR |
163 | item "~/.vim/vimrc" |
164 | install $SCRIPT_DIR/vimrc $VIMDIR/vimrc |
165 | item "~/.vim/autoload/plug.vim" |
166 | if [ ! -f $VIMDIR/autoload/plug.vim ]; then |
167 | curl -fLso $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
168 | fi |
169 | fi |
170 |
|
171 | # Done |
172 | echo -e " \e[1;33mDONE\e[0m" |
173 |
|