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
44 command -v instantdotfiles && instantdotfiles
47 if ! iconf -i rangerplugins && command -v rangerplugins; then
49 echo "installing ranger plugins"
50 mkdir -p ~/.config/ranger/plugins
51 cp -r /usr/share/rangerplugins/* ~/.config/ranger/plugins/
52 iconf -i rangerplugins 1
55 # find out if it's a live session
56 if [ -e /usr/share/liveutils ] &>/dev/null; then
58 echo "live session detected"
61 if iconf -i islaptop; then
62 export ISLAPTOP="true"
63 echo "laptop detected"
69 if [ -n "$ISLIVE" ]; then
76 # optionally disable status bar
77 if iconf -i nobar; then
78 NMON=$(iconf names | wc -l)
79 for i in $(eval "echo {1..$NMON}"); do
80 echo "found monitor $i"
81 xdotool key super+comma
86 if [ -n "$ISRASPI" ]; then
87 # enable double drawing for moving floating windows
88 # greatly increases smoothness
90 if ! [ -e ~/.config/instantos/israspi ]; then
91 echo "marking machine as raspi"
92 mkdir -p ~/.config/instantos
93 touch ~/.config/instantos/israspi
94 # logo does not work on raspi
99 if ! iconf -i notheming; then
102 iconf -i instantthemes 1
104 # dynamically switch between light and dark gtk theme
106 if [ "$DATEHOUR" -gt "20" ] || [ "$DATEHOUR" -lt "7" ]; then
108 touch /tmp/instantdarkmode
109 [ -e /tmp/instantlightmode ] && rm /tmp/instantlightmode
112 touch /tmp/instantlightmode
113 [ -e /tmp/instantdarkmode ] && rm /tmp/instantdarkmode
116 touch /tmp/instantlightmode
119 mkdir -p /tmp/notifications &>/dev/null
120 if ! pgrep dunst; then
122 # wait for theming before starting dunst
123 if [ -e /tmp/instantdarkmode ] || [ -e /tmp/instantlightmode ]; then
131 if ! iconf -i nowallpaper; then
136 # set up oh-my-zsh config if not existing already
137 iconf -i nozsh || instantshell &
139 # fix resolution on virtual machine
140 if ! iconf -i novmfix && grep -q 'hypervisor' /proc/cpuinfo; then
141 # indicator file only exists on kvm/QEMU on amd
142 if [ -e /opt/instantos/kvm ]; then
144 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
146 # iconf -i noanimations 1
147 if ! iconf -i potato && ! iconf -i nopotato; then
148 if echo "please set your video card to virtio or passthrough
149 QXL on AMD on QEMU/kvm has been known to cause a severe Xorg memory leak.
150 Disabling compositing makes this somewhat bearable,
151 but switching really is recommended.
152 (or switch to virtualbox, no issues there...)
153 Disable compositing for this VM?" | imenu -C; then
157 if ! imenu -c "ask again next time?"; then
167 if ! [ -e /opt/instantos/guestadditions ]; then
168 if lsmod | grep -q vboxguest; then
169 echo "guestadditions detected"
171 if echo "virtual machine detected.
172 Would you like to switch to a 1080p resolution?" | imenu -C; then
173 echo "applying virtual machine workaround"
174 /usr/share/instantassist/assists/t/v.sh
176 if [ -z "$ISLIVE" ]; then
177 if ! imenu -c "ask again next session"; then
187 echo "not a live session"
188 if [ -e /opt/instantos/installtrigger ]; then
189 zenity --info --text "finishing installation in background" &
191 # ask for password if postinstall already ran
192 if ! timeout 2 sudo echo test; then
193 instantsudo instantpostinstall
194 sudo rm /opt/instantos/installtrigger
196 sudo instantpostinstall
202 cd ~/instantos || exit 1
203 if ! iconf -i max; then
207 if [ -e ~/instantos/monitor.sh ]; then
208 echo "restoring resolution"
209 bash ~/instantos/monitor.sh &
210 elif [ -e ~/.config/autorandr/instantos/config ]; then
211 echo "restoring autorandr resolution"
212 autorandr instantos &
215 if checkinternet; then
218 # fall back to already installed wallpapers
219 instantwallpaper offline
220 for i in $(seq 10); do
221 if checkinternet; then
230 # apply keybpard layout
231 if iconf layout; then
232 setxkbmap -layout "$(iconf layout)"
234 CURLOCALE=$(locale | grep LANG | sed 's/.*=\(.*\)\..*/\1/')
240 echo "no keyboard layout found for your locale"
246 if iconf mousespeed; then
247 echo "setting mousespeed"
248 instantmouse s "$(iconf mousespeed)"
251 if iconf -i reversemouse; then
257 if ! iconf -i noconky; then
258 shuf /usr/share/instantwidgets/tooltips.txt | head -1 >~/.cache/tooltip
259 conky -c /usr/share/instantwidgets/tooltips.conf &
263 echo "live session detected"
266 echo "disabling compositing for qxl graphics"
267 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
271 sudo systemctl start NetworkManager
274 iconf -i wifiapplet 1
275 instantwallpaper set /usr/share/instantwallpaper/defaultphoto.png
276 conky -c /usr/share/instantwidgets/install.conf &
279 if ! pgrep python; then
287 # make built in status optional
288 if ! iconf -i nostatus; then
289 source /usr/bin/instantstatus &
293 HEIGHT=$(iconf max | grep -o '[0-9]*$')
294 WIDTH=$(iconf max | grep -o '^[0-9]*')
295 RESOLUTION="$((HEIGHT * WIDTH))"
296 DPIMESSAGE="HiDpi settings can be found in settings->display->dpi"
297 if ! imenu -C <<<"high resolution display detected
298 would you like to enable HiDpi?"; then
299 if imenu -c "ask again next time?"; then
303 imenu -m "$DPIMESSAGE"
307 DPI=$(imenu -i 'enter dpi (default is 96)')
308 while ! [ "$DPI" -eq "$DPI" ] || [ "$DPI" -gt 500 ] || [ "$DPI" -lt "20" ]; do
309 imenu -m "please enter a number between 20 and 500 (default is 96), enter q to skip hidpi"
310 DPI=$(imenu -i 'enter dpi (default is 96)')
311 if grep -q 'q' <<<"$DPI"; then
312 imenu -m "$DPIMESSAGE"
321 imenu -m "a restart is needed to globally apply dpi"
325 if ! iconf -i nohidpi && iconf max; then
326 if [ "$RESOLUTION" -gt 8294000 ]; then
332 if iconf -i potato || iconf -i nocompositing; then
333 echo "compositing disabled"
343 xfce4-power-manager &
345 # auto open menu when connecting/disconnecting monitor
346 if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
348 if nvidia-xconfig --query-gpu-info; then
349 DISPLAYCOUNT="$(nvidia-xconfig --query-gpu-info | grep -oi 'number of dis.*' | grep -o '[0-9]*')"
351 DISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
354 if [ "$DISPLAYCOUNT" -eq "$DISPLAYCOUNT" ]; then
356 NEWDISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
357 if ! [ "$DISPLAYCOUNT" = "$NEWDISPLAYCOUNT" ]; then
358 notify-send "display changed"
359 echo "displays changed"
360 if [ "$NEWDISPLAYCOUNT" -gt 1 ]; then
362 echo "multi monitor setup"
366 DISPLAYCOUNT="$NEWDISPLAYCOUNT"
372 echo "error detecting display count"
377 if iconf -b welcome; then
381 # prompt to fix configuration if installed from the AUR
382 if ! iconf -i norootinstall && ! islive; then
383 if ! command -v imenu || ! command -v instantmenu; then
384 notify-send "please install instantmenu and imenu"
386 if ! [ -e /opt/instantos/rootinstall ]; then
387 imenu -m "instantOS is missing some configuration"
388 while ! [ -e /tmp/rootskip ]; do
389 if imenu -c "would you like to fix that?"; then
390 touch /tmp/topinstall
391 instantsudo bash -c "instantutils root"
394 if imenu -c "Are you sure? this will prevent parts of instantOS from functioning correctly"; then
404 TODAY="$(date '+%d%m')"
405 OTHERTODAY="$(iconf today)"
407 if [ -z "$OTHERTODAY" ]; then
408 iconf today "$(date '+%d%m')"
409 OTHERTODAY="$(iconf today)"
412 if ! [ "$TODAY" = "$OTHERTODAY" ]; then
413 iconf today "$(date '+%d%m')"
414 echo "running daily routine"
418 # displays message user opens the terminal for the first time
419 if ! iconf -i nohelp; then
420 if ! grep -q 'instantterminalhelp' ~/.zshrc; then
421 echo '[[ $- == *i* ]] && instantterminalhelp' >>~/.zshrc
426 [ -n "$2" ] || return
427 iconf -i "$1" || return
431 # run command if iconf option is set
433 if iconf -i "$1"; then
439 if iconf savebright; then
440 export NOBRIGHTMESSAGE=true
441 /usr/share/instantassist/utils/b.sh 2 "$(iconf savebright)"
444 confkey highfps "super+alt+shift+d"
445 confkey noanimations "super+alt+shift+s"
447 if iconf -i alttab; then
448 instantwmctrl alttab 1
450 instantwmctrl alttab 0
454 confcommand desktopicons rox --pinboard Default
456 confcommand udiskie udiskie -t
458 confcommand clipmanager clipmenud
460 # user declared autostart
461 if [ -e ~/.config/instantos/autostart.sh ]; then
462 bash ~/.config/instantos/autostart.sh
466 if ! iconf -i noupdates && [ -z "$ISLIVE" ]; then
468 if checkinternet; then
471 if command -v checkinternet; then
474 if checkinternet; then
483 # start processes that need to be kept running
486 if iconf -i wifiapplet && ! pgrep nm-applet; then
487 echo "starting bluetooth applet"
491 if iconf -i bluetoothapplet && ! pgrep blueman-applet; then
492 echo "starting bluetooth applet"
496 if iconf -i alttab && ! pgrep alttab; then
497 alttab -fg "#ffffff" -bg "#292F3A" -frame "#5293E1" -d 0 -s 1 -t 128x150 -i 127x64 -w 1 -vp pointer &