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 setxkbmap -layout "$(iconf layout)"
247 CURLOCALE=$(locale | grep LANG | sed 's/.*=\(.*\)\..*/\1/')
253 echo "no keyboard layout found for your locale"
258 if ! iconf -i noconky; then
259 shuf /usr/share/instantwidgets/tooltips.txt | head -1 >~/.cache/tooltip
260 conky -c /usr/share/instantwidgets/tooltips.conf &
264 echo "live session detected"
267 echo "disabling compositing for qxl graphics"
268 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
272 sudo systemctl start NetworkManager
275 iconf -i wifiapplet 1
276 instantwallpaper set /usr/share/instantwallpaper/defaultphoto.png
277 conky -c /usr/share/instantwidgets/install.conf &
280 if ! pgrep python; then
288 # make built in status optional
289 if ! iconf -i nostatus; then
290 source /usr/bin/instantstatus &
294 HEIGHT=$(iconf max | grep -o '[0-9]*$')
295 WIDTH=$(iconf max | grep -o '^[0-9]*')
296 RESOLUTION="$((HEIGHT * WIDTH))"
297 DPIMESSAGE="HiDpi settings can be found in settings->display->dpi"
298 if ! imenu -C <<<"high resolution display detected
299 would you like to enable HiDpi?"; then
300 if imenu -c "ask again next time?"; then
304 imenu -m "$DPIMESSAGE"
308 DPI=$(imenu -i 'enter dpi (default is 96)')
309 while ! [ "$DPI" -eq "$DPI" ] || [ "$DPI" -gt 500 ] || [ "$DPI" -lt "20" ]; do
310 imenu -m "please enter a number between 20 and 500 (default is 96), enter q to skip hidpi"
311 DPI=$(imenu -i 'enter dpi (default is 96)')
312 if grep -q 'q' <<<"$DPI"; then
313 imenu -m "$DPIMESSAGE"
322 imenu -m "a restart is needed to globally apply dpi"
326 if ! iconf -i nohidpi && iconf max; then
327 if [ "$RESOLUTION" -gt 8294000 ]; then
333 if iconf -i potato || iconf -i nocompositing; then
334 echo "compositing disabled"
339 xfce4-power-manager &
341 # auto open menu when connecting/disconnecting monitor
342 if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
344 if nvidia-xconfig --query-gpu-info; then
345 DISPLAYCOUNT="$(nvidia-xconfig --query-gpu-info | grep -oi 'number of dis.*' | grep -o '[0-9]*')"
347 DISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
350 if [ "$DISPLAYCOUNT" -eq "$DISPLAYCOUNT" ]; then
352 NEWDISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
353 if ! [ "$DISPLAYCOUNT" = "$NEWDISPLAYCOUNT" ]; then
354 notify-send "display changed"
355 echo "displays changed"
356 if [ "$NEWDISPLAYCOUNT" -gt 1 ]; then
358 echo "multi monitor setup"
362 DISPLAYCOUNT="$NEWDISPLAYCOUNT"
368 echo "error detecting display count"
373 if iconf -b welcome; then
377 # prompt to fix configuration if installed from the AUR
378 if ! iconf -i norootinstall && ! islive; then
379 if ! command -v imenu || ! command -v instantmenu; then
380 notify-send "please install instantmenu and imenu"
382 if ! [ -e /opt/instantos/rootinstall ]; then
383 imenu -m "instantOS is missing some configuration"
384 while ! [ -e /tmp/rootskip ]; do
385 if imenu -c "would you like to fix that?"; then
386 touch /tmp/topinstall
387 instantsudo bash -c "instantutils root"
390 if imenu -c "Are you sure? this will prevent parts of instantOS from functioning correctly"; then
400 TODAY="$(date '+%d%m')"
401 OTHERTODAY="$(iconf today)"
403 if [ -z "$OTHERTODAY" ]; then
404 iconf today "$(date '+%d%m')"
405 OTHERTODAY="$(iconf today)"
408 if ! [ "$TODAY" = "$OTHERTODAY" ]; then
409 iconf today "$(date '+%d%m')"
410 echo "running daily routine"
414 # displays message user opens the terminal for the first time
415 if ! iconf -i nohelp; then
416 if ! grep -q 'instantterminalhelp' ~/.zshrc; then
417 echo '[[ $- == *i* ]] && instantterminalhelp' >>~/.zshrc
422 [ -n "$2" ] || return
423 iconf -i "$1" || return
427 # run command if iconf option is set
429 if iconf -i "$1"; then
435 if iconf savebright; then
436 export NOBRIGHTMESSAGE=true
437 /usr/share/instantassist/utils/b.sh 2 "$(iconf savebright)"
440 confkey highfps "super+alt+shift+d"
441 confkey noanimations "super+alt+shift+s"
443 if iconf -i alttab; then
444 instantwmctrl alttab 3
446 instantwmctrl alttab 1
450 confcommand desktopicons rox --pinboard Default
452 confcommand udiskie udiskie -t
454 confcommand clipmanager clipmenud
456 # user declared autostart
457 if [ -e ~/.config/instantos/autostart.sh ]; then
458 bash ~/.config/instantos/autostart.sh
462 if ! iconf -i noupdates && [ -z "$ISLIVE" ]; then
464 if checkinternet; then
467 if command -v checkinternet; then
470 if checkinternet; then
479 # needed for things like the pamac auth prompt
486 # start processes that need to be kept running
489 # check if new device has been plugged in
490 XINPUTSUM="$(xinput | md5sum)"
491 if ! [ "$OLDXSUM" = "$XINPUTSUM" ]; then
497 if iconf -i wifiapplet && ! pgrep nm-applet; then
498 echo "starting wifi applet"
502 if iconf -i bluetoothapplet && ! pgrep blueman-applet; then
503 echo "starting bluetooth applet"
508 if iconf -i alttab && ! pgrep alttab; then
509 alttab -fg "#ffffff" -bg "#292F3A" -frame "#5293E1" -d 0 -s 1 -t 128x150 -i 127x64 -w 1 -vp pointer &