3 ###############################################
4 ## script for instantOS autostart ##
5 ###############################################
7 INSTANTVERSION="$(cat /usr/share/instantutils/version)"
8 if iconf version && [ "$(iconf version)" = "$INSTANTVERSION" ]; then
9 echo "version check successful"
10 echo "running version $INSTANTVERSION"
12 echo "running update hooks"
13 /usr/share/instantutils/userinstall.sh
14 iconf -i userinstall 1
15 iconf version "$INSTANTVERSION"
20 /usr/share/instantutils/wmautostart.sh
22 # architecture detection
24 if uname -m | grep -q '^arm'; then
28 if iconf -i noautostart; then
29 echo "autostart disabled"
33 if [ "$(ps aux | grep bash | grep instantautostart | wc -l)" -gt 3 ]; then
34 echo "already running"
42 if ! iconf -r keepdotfiles && ! iconf -i nodotfiles; then
43 command -v instantdotfiles && instantdotfiles
46 if ! iconf -i rangerplugins && command -v rangerplugins; then
48 echo "installing ranger plugins"
49 mkdir -p ~/.config/ranger/plugins
50 cp -r /usr/share/rangerplugins/* ~/.config/ranger/plugins/
51 iconf -i rangerplugins 1
54 # find out if it's a live session
55 if [ -e /usr/share/liveutils ] &>/dev/null; then
57 echo "live session detected"
60 if iconf -i islaptop; then
61 export ISLAPTOP="true"
62 echo "laptop detected"
68 if [ -n "$ISLIVE" ]; then
77 if iconf mousespeed; then
78 echo "setting mousespeed"
79 instantmouse s "$(iconf mousespeed)"
82 if iconf -i reversemouse; then
89 # optionally disable status bar
90 if iconf -i nobar; then
91 NMON=$(iconf names | wc -l)
92 for i in $(eval "echo {1..$NMON}"); do
93 echo "found monitor $i"
94 xdotool key super+comma
99 if [ -n "$ISRASPI" ]; then
100 # enable double drawing for moving floating windows
101 # greatly increases smoothness
103 if ! [ -e ~/.config/instantos/israspi ]; then
104 echo "marking machine as raspi"
105 mkdir -p ~/.config/instantos
106 touch ~/.config/instantos/israspi
107 # logo does not work on raspi
112 if ! iconf -i notheming; then
115 iconf -i instantthemes 1
117 # dynamically switch between light and dark gtk theme
119 if [ "$DATEHOUR" -gt "20" ] || [ "$DATEHOUR" -lt "7" ]; then
121 touch /tmp/instantdarkmode
122 [ -e /tmp/instantlightmode ] && rm /tmp/instantlightmode
125 touch /tmp/instantlightmode
126 [ -e /tmp/instantdarkmode ] && rm /tmp/instantdarkmode
129 touch /tmp/instantlightmode
132 mkdir -p /tmp/notifications &>/dev/null
133 if ! pgrep dunst; then
135 # wait for theming before starting dunst
136 if [ -e /tmp/instantdarkmode ] || [ -e /tmp/instantlightmode ]; then
144 if ! iconf -i nowallpaper; then
149 # set up oh-my-zsh config if not existing already
150 iconf -i nozsh || instantshell &
152 # fix resolution on virtual machine
153 if ! iconf -i novmfix && grep -q 'hypervisor' /proc/cpuinfo; then
154 # indicator file only exists on kvm/QEMU on amd
155 if [ -e /opt/instantos/kvm ]; then
157 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
159 # iconf -i noanimations 1
160 if ! iconf -i potato && ! iconf -i nopotato; then
161 if echo "please set your video card to virtio or passthrough
162 QXL on AMD on QEMU/kvm has been known to cause a severe Xorg memory leak.
163 Disabling compositing makes this somewhat bearable,
164 but switching really is recommended.
165 (or switch to virtualbox, no issues there...)
166 Disable compositing for this VM?" | imenu -C; then
170 if ! imenu -c "ask again next time?"; then
180 if ! [ -e /opt/instantos/guestadditions ]; then
181 if lsmod | grep -q vboxguest; then
182 echo "guestadditions detected"
184 if echo "virtual machine detected.
185 Would you like to switch to a 1080p resolution?" | imenu -C; then
186 echo "applying virtual machine workaround"
187 /usr/share/instantassist/assists/t/v.sh
189 if [ -z "$ISLIVE" ]; then
190 if ! imenu -c "ask again next session"; then
200 echo "not a live session"
201 if [ -e /opt/instantos/installtrigger ]; then
202 zenity --info --text "finishing installation in background" &
204 # ask for password if postinstall already ran
205 if ! timeout 2 sudo echo test; then
206 instantsudo instantpostinstall
207 sudo rm /opt/instantos/installtrigger
209 sudo instantpostinstall
215 cd ~/instantos || exit 1
216 if ! iconf -i max; then
220 if [ -e ~/instantos/monitor.sh ]; then
221 echo "restoring resolution"
222 bash ~/instantos/monitor.sh &
223 elif [ -e ~/.config/autorandr/instantos/config ]; then
224 echo "restoring autorandr resolution"
225 autorandr instantos &
228 if checkinternet; then
231 # fall back to already installed wallpapers
232 instantwallpaper offline
233 for i in $(seq 10); do
234 if checkinternet; then
243 # apply keybpard layout
244 if ! iconf layout; then
245 if iconf -r layout; then
246 iconf layout "$(iconf -r layout)"
250 KEYLAYOUT="$(iconf layout:us)"
251 setxkbmap -layout "$KEYLAYOUT"
253 if ! iconf -i noconky; then
254 shuf /usr/share/instantwidgets/tooltips.txt | head -1 >~/.cache/tooltip
255 conky -c /usr/share/instantwidgets/tooltips.conf &
259 echo "live session detected"
262 echo "disabling compositing for qxl graphics"
263 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
267 sudo systemctl start NetworkManager
270 iconf -i wifiapplet 1
271 instantwallpaper set /usr/share/instantwallpaper/defaultphoto.png
272 conky -c /usr/share/instantwidgets/install.conf &
275 if ! pgrep python; then
283 # make built in status optional
284 if ! iconf -i nostatus; then
285 source /usr/bin/instantstatus &
289 HEIGHT=$(iconf max | grep -o '[0-9]*$')
290 WIDTH=$(iconf max | grep -o '^[0-9]*')
291 RESOLUTION="$((HEIGHT * WIDTH))"
292 DPIMESSAGE="HiDpi settings can be found in settings->display->dpi"
293 if ! imenu -C <<<"high resolution display detected
294 would you like to enable HiDpi?"; then
295 if imenu -c "ask again next time?"; then
299 imenu -m "$DPIMESSAGE"
303 DPI=$(imenu -i 'enter dpi (default is 96)')
304 while ! [ "$DPI" -eq "$DPI" ] || [ "$DPI" -gt 500 ] || [ "$DPI" -lt "20" ]; do
305 imenu -m "please enter a number between 20 and 500 (default is 96), enter q to skip hidpi"
306 DPI=$(imenu -i 'enter dpi (default is 96)')
307 if grep -q 'q' <<<"$DPI"; then
308 imenu -m "$DPIMESSAGE"
317 imenu -m "a restart is needed to globally apply dpi"
321 if ! iconf -i nohidpi && iconf max; then
322 if [ "$RESOLUTION" -gt 8294000 ]; then
328 if iconf -i potato || iconf -i nocompositing; then
329 echo "compositing disabled"
334 xfce4-power-manager &
336 # auto open menu when connecting/disconnecting monitor
337 if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
339 if nvidia-xconfig --query-gpu-info; then
340 DISPLAYCOUNT="$(nvidia-xconfig --query-gpu-info | grep -oi 'number of dis.*' | grep -o '[0-9]*')"
342 DISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
345 if [ "$DISPLAYCOUNT" -eq "$DISPLAYCOUNT" ]; then
347 NEWDISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
348 if ! [ "$DISPLAYCOUNT" = "$NEWDISPLAYCOUNT" ]; then
349 notify-send "display changed"
350 echo "displays changed"
351 if [ "$NEWDISPLAYCOUNT" -gt 1 ]; then
353 echo "multi monitor setup"
357 DISPLAYCOUNT="$NEWDISPLAYCOUNT"
363 echo "error detecting display count"
368 if iconf -b welcome; then
372 # prompt to fix configuration if installed from the AUR
373 if ! iconf -i norootinstall && ! islive; then
374 if ! command -v imenu || ! command -v instantmenu; then
375 notify-send "please install instantmenu and imenu"
377 if ! [ -e /opt/instantos/rootinstall ]; then
378 imenu -m "instantOS is missing some configuration"
379 while ! [ -e /tmp/rootskip ]; do
380 if imenu -c "would you like to fix that?"; then
381 touch /tmp/topinstall
382 instantsudo bash -c "instantutils root"
385 if imenu -c "Are you sure? this will prevent parts of instantOS from functioning correctly"; then
395 TODAY="$(date '+%d%m')"
396 OTHERTODAY="$(iconf today)"
398 if [ -z "$OTHERTODAY" ]; then
399 iconf today "$(date '+%d%m')"
400 OTHERTODAY="$(iconf today)"
403 if ! [ "$TODAY" = "$OTHERTODAY" ]; then
404 iconf today "$(date '+%d%m')"
405 echo "running daily routine"
409 # displays message user opens the terminal for the first time
410 if ! iconf -i nohelp; then
411 if ! grep -q 'instantterminalhelp' ~/.zshrc; then
412 echo '[[ $- == *i* ]] && instantterminalhelp' >>~/.zshrc
417 [ -n "$2" ] || return
418 iconf -i "$1" || return
422 # run command if iconf option is set
424 if iconf -i "$1"; then
430 if iconf savebright; then
431 export NOBRIGHTMESSAGE=true
432 /usr/share/instantassist/utils/b.sh 2 "$(iconf savebright)"
435 confkey highfps "super+alt+shift+d"
436 confkey noanimations "super+alt+shift+s"
438 if iconf -i alttab; then
439 instantwmctrl alttab 3
441 instantwmctrl alttab 1
445 confcommand desktopicons rox --pinboard Default
447 confcommand udiskie udiskie -t
449 confcommand clipmanager clipmenud
451 # user declared autostart
452 if [ -e ~/.config/instantos/autostart.sh ]; then
453 bash ~/.config/instantos/autostart.sh
457 if ! iconf -i noupdates && [ -z "$ISLIVE" ]; then
459 if checkinternet; then
462 if command -v checkinternet; then
465 if checkinternet; then
474 # needed for things like the pamac auth prompt
480 # start processes that need to be kept running
483 # check if new device has been plugged in
484 XINPUTSUM="$(xinput | md5sum)"
485 if ! [ "$OLDXSUM" = "$XINPUTSUM" ]; then
491 if iconf -i wifiapplet && ! pgrep nm-applet; then
492 echo "starting wifi applet"
496 if iconf -i bluetoothapplet && ! pgrep blueman-applet; then
497 echo "starting bluetooth applet"
501 if iconf -i alttab && ! pgrep alttab; then
502 alttab -fg "#ffffff" -bg "#292F3A" -frame "#5293E1" -d 0 -s 1 -t 128x150 -i 127x64 -w 1 -vp pointer &