OSDN Git Service

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