OSDN Git Service

start rebranding
[instantos/instantOS.git] / install.sh
1 #!/usr/bin/env bash
2
3 #############################################
4 ## installs all instantOS tools            ##
5 #############################################
6
7 echo "installing instantOS tools"
8
9 RAW="https://raw.githubusercontent.com"
10 source <(curl -s $RAW/paperbenni/bash/master/import.sh)
11 pb install
12 pb git
13
14 LINK="$RAW/paperbenni/suckless/master"
15
16 # fetches and installs program from this repo
17 gprogram() {
18     echo "installing $1"
19     wget -q "$RAW/paperbenni/suckless/master/programs/$1"
20     usrbin -f "$1"
21 }
22
23 gclone() {
24     echo "cloning $1"
25     gitclone $@ &>/dev/null
26 }
27
28 iclone() {
29     echo "cloning $1"
30     gitclone instantOS/$@ &>/dev/null
31 }
32
33 # adds permanent global environment variable
34 addenv() {
35     [ -e /etc/environment ] || sudo touch /etc/environment
36     if [ "$1" = "-f" ]; then
37         local FORCE="true"
38         shift 1
39     fi
40
41     if grep -q "$1=" /etc/environment; then
42         if [ -z "$FORCE" ]; then
43             echo "key already there"
44             return 1
45         else
46             sudo sed -i "s/$1=.*/$1=$2/g" /etc/environment
47         fi
48     else
49         echo "$1=$2" | sudo tee -a /etc/environment
50     fi
51 }
52
53 addenv -f "QT_QPA_PLATFORMTHEME" "qt5ct"
54 command -v nvim &>/dev/null && addenv -f "EDITOR" "$(which nvim)"
55
56 THEME="${1:-dracula}"
57 echo "using theme $THEME"
58 [ -e ~/paperbenni ] || mkdir ~/paperbenni
59 echo "$THEME" >~/paperbenni/.theme
60
61 rm -rf suckless
62 mkdir suckless
63 cd suckless
64
65 iclone instantWM
66
67 #iclone instantMENU // weiter
68
69 # needed for slock
70 if grep -q 'nobody' </etc/groups || grep -q 'nobody' </etc/group; then
71     echo "nobody workaround not required"
72 else
73     sudo groupadd nobody
74 fi
75
76 # add group and add user to group
77 ugroup() {
78     if groups | grep -q "$1"; then
79         echo "user is member of $1"
80         return
81     else
82         sudo groupadd "$1"
83         sudo gpasswd -a $USER $1
84     fi
85 }
86
87 ugroup video
88 ugroup input
89
90 gclone slock
91
92
93 for FOLDER in ./*; do
94     if ! [ -d "$FOLDER" ]; then
95         echo "skipping $FOLDER"
96         continue
97     fi
98     pushd "$FOLDER"
99     if ! [ -e build.sh ]; then
100         rm config.h
101         make &>/dev/null
102         sudo make install &>/dev/null
103     else
104         chmod +x ./build.sh
105         ./build.sh "$THEME" &>/dev/null
106     fi
107     popd
108 done
109
110 # session for lightdm
111 wget -q $RAW/paperbenni/suckless/master/instantwm.desktop
112 sudo mv instantwm.desktop /usr/share/xsessions/
113
114 # x session wrapper
115 gprogram startinstantwm
116 # shutdown popup that breaks restart loop
117 gprogram instantshutdown
118
119 gprogram autoclicker
120
121 # dmenu run but in terminal emulator st
122 # only supported terminal apps (less to search through)
123 gprogram instantterm
124
125 gprogram instantswitch
126 gprogram instantnotify
127
128 # for that extra kick when doingg a typo
129 gprogram sll
130
131 curl "$LINK/termprograms.txt" >~/.cache/termprograms.txt
132
133 if ! [ ~/.local/share/fonts/symbola.ttf ]; then
134     mkdir -p ~/.local/share/fonts
135     cd ~/.local/share/fonts
136     echo "installing symbola font"
137     wget -q "http://symbola.surge.sh/symbola.ttf"
138 fi
139
140 cd
141
142 # laptop specific stuff
143 if acpi | grep -q '[0-9]%'; then
144     # config file to indicate being a laptop
145     touch .cache/islaptop
146
147     # fix tap to click not working with tiling wms
148     if ! [ -e /etc/X11/xorg.conf.d/90-touchpad.conf ] ||
149         ! cat /etc/X11/xorg.conf.d/90-touchpad.conf | grep -iq 'tapping.*"on"'; then
150
151         sudo mkdir -p /etc/X11/xorg.conf.d && sudo tee /etc/X11/xorg.conf.d/90-touchpad.conf <<'EOF' 1>/dev/null
152 Section "InputClass"
153         Identifier "touchpad"
154         MatchIsTouchpad "on"
155         Driver "libinput"
156         Option "Tapping" "on"
157 EndSection
158
159 EOF
160     fi
161
162 fi
163
164 curl -s "$RAW/paperbenni/suckless/master/monitor.sh" | bash
165 cd
166
167 # three and four finger swipes on laptop
168 if ! command -v libinput-gestures &>/dev/null; then
169     cd /tmp
170     git clone --depth=1 https://github.com/bulletmark/libinput-gestures.git
171     cd libinput-gestures
172     sudo make install
173     cd ..
174     rm -rf libinput-gestures
175 fi
176
177 cd
178
179 # auto start script with instantWM
180 ls .instantos &>/dev/null || mkdir .instantos
181 curl $LINK/autostart.sh >.instantos/autostart.sh
182 chmod +x .instantos/autostart.sh
183
184 # set up multi monitor config for dswitch
185 if ! [ -e paperbenni/ismultimonitor ]; then
186     if xrandr | grep ' connected' | grep -Eo '[0-9]{3,}x' |
187         grep -o '[0-9]*' | wc -l | grep -q '2'; then
188         mkdir paperbenni &>/dev/null
189         xrandr | grep ' connected' | grep -Eo '[0-9]{3,}x' |
190             grep -o '[0-9]*' >paperbenni/ismultimonitor
191         echo "$(wc -l paperbenni/ismultimonitor) monitors detected"
192     else
193         echo "not a multi monitor setup"
194     fi
195 else
196     echo "monitor config: "
197     cat paperbenni/ismultimonitor
198     echo ""
199 fi
200
201 cd
202
203 # install wmutils
204 if ! command -v pfw &>/dev/null; then
205     cd /tmp
206     if git clone --depth=1 https://github.com/wmutils/core.git; then
207         cd core
208         make
209         sudo make install
210         cd ..
211         rm -rf core
212     fi
213 fi
214
215 cd
216
217 # install win + a menus for shortcuts like screenshots and shutdown
218 curl -s $RAW/paperbenni/menus/master/install.sh | bash
219
220 # drag and drop x utility for ranger
221 if ! command -v dragon &>/dev/null; then
222     cd /tmp
223     git clone --depth=1 https://github.com/mwh/dragon.git &>/dev/null
224     cd dragon
225     make
226     make install
227     cd ..
228     rm -rf dragon
229 fi
230
231 cd
232 mkdir -p paperbenni/notifications &>/dev/null
233
234 # gets executed by dunst on notification
235 curl "$RAW/paperbenni/suckless/master/programs/dunsttrigger" >~/paperbenni/notifications/dunsttrigger
236 chmod +x ~/paperbenni/notifications/dunsttrigger
237 wget -O ~/paperbenni/notifications/notification.ogg "https://notificationsounds.com/notification-sounds/me-too-603/download/ogg"
238
239 cd
240 mkdir instantos/wallpapers
241 curl -s "$RAW/instantOS/instantWALLPAPER/master/wall.sh" > intantos/wallpapers/wall.sh
242 chmod +x intantos/wallpapers/wall.sh
243
244 # set instantwm as default for lightdm
245 echo '[Desktop]' >.dmrc
246 echo 'Session=instantwm' >>.dmrc
247 if [ -e /etc/lightdm/lightdm.conf ]; then
248     sudo sed -i 's/^user-session=.*/user-session=instantwm/g' /etc/lightdm/lightdm.conf
249 fi
250
251 # fix java gui appearing empty on instantWM
252 if ! grep -q 'instantwm' </etc/profile; then
253     echo "fixing java windows for instantwm in /etc/profile"
254     echo '# fix instantwm java windows' | sudo tee -a /etc/profile
255     echo 'export _JAVA_AWT_WM_NONREPARENTING=1' | sudo tee -a /etc/profile
256 else
257     echo "java workaround already applied"
258 fi