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 command -v instantdotfiles && instantdotfiles
44 if ! iconf -i rangerplugins && command -v rangerplugins; then
46 echo "installing ranger plugins"
47 mkdir -p ~/.config/ranger/plugins
48 cp -r /usr/share/rangerplugins/* ~/.config/ranger/plugins/
49 iconf -i rangerplugins 1
52 # find out if it's a live session
53 if [ -e /usr/share/liveutils ] &>/dev/null; then
55 echo "live session detected"
58 if iconf -i islaptop; then
59 export ISLAPTOP="true"
60 echo "laptop detected"
66 if [ -n "$ISLIVE" ]; then
73 # optionally disable status bar
74 if iconf -i nobar; then
75 NMON=$(iconf names | wc -l)
76 for i in $(eval "echo {1..$NMON}"); do
77 echo "found monitor $i"
78 xdotool key super+comma
83 if [ -n "$ISRASPI" ]; then
84 # enable double drawing for moving floating windows
85 # greatly increases smoothness
87 if ! [ -e ~/.config/instantos/israspi ]; then
88 echo "marking machine as raspi"
89 mkdir -p ~/.config/instantos
90 touch ~/.config/instantos/israspi
91 # logo does not work on raspi
96 if ! iconf -i notheming; then
99 iconf -i instantthemes 1
101 # dynamically switch between light and dark gtk theme
103 if [ "$DATEHOUR" -gt "20" ] || [ "$DATEHOUR" -lt "7" ]; then
105 touch /tmp/instantdarkmode
106 [ -e /tmp/instantlightmode ] && rm /tmp/instantlightmode
109 touch /tmp/instantlightmode
110 [ -e /tmp/instantdarkmode ] && rm /tmp/instantdarkmode
113 touch /tmp/instantlightmode
116 mkdir -p /tmp/notifications &>/dev/null
117 if ! pgrep dunst; then
119 # wait for theming before starting dunst
120 if [ -e /tmp/instantdarkmode ] || [ -e /tmp/instantlightmode ]; then
128 if ! iconf -i nowallpaper; then
133 # set up oh-my-zsh config if not existing already
134 iconf -i nozsh || instantshell &
136 # fix resolution on virtual machine
137 if ! iconf -i novmfix && grep -q 'hypervisor' /proc/cpuinfo; then
138 # indicator file only exists on kvm/QEMU on amd
139 if [ -e /opt/instantos/kvm ]; then
141 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
143 # iconf -i noanimations 1
144 if ! iconf -i potato && ! iconf -i nopotato; then
145 if echo "please set your video card to virtio or passthrough
146 QXL on AMD on QEMU/kvm has been known to cause a severe Xorg memory leak.
147 Disabling compositing makes this somewhat bearable,
148 but switching really is recommended.
149 (or switch to virtualbox, no issues there...)
150 Disable compositing for this VM?" | imenu -C; then
154 if ! imenu -c "ask again next time?"; then
164 if ! [ -e /opt/instantos/guestadditions ]; then
165 if lsmod | grep -q vboxguest; then
166 echo "guestadditions detected"
168 if echo "virtual machine detected.
169 Would you like to switch to a 1080p resolution?" | imenu -C; then
170 echo "applying virtual machine workaround"
171 /usr/share/instantassist/assists/t/v.sh
173 if [ -z "$ISLIVE" ]; then
174 if ! imenu -c "ask again next session"; then
184 echo "not a live session"
185 if [ -e /opt/instantos/installtrigger ]; then
186 zenity --info --text "finishing installation in background" &
188 # ask for password if postinstall already ran
189 if ! timeout 2 sudo echo test; then
190 instantsudo instantpostinstall
191 sudo rm /opt/instantos/installtrigger
193 sudo instantpostinstall
199 cd ~/instantos || exit 1
200 if ! iconf -i max; then
204 if [ -e ~/instantos/monitor.sh ]; then
205 echo "restoring resolution"
206 bash ~/instantos/monitor.sh &
207 elif [ -e ~/.config/autorandr/instantos/config ]; then
208 echo "restoring autorandr resolution"
209 autorandr instantos &
212 if checkinternet; then
215 # fall back to already installed wallpapers
216 instantwallpaper offline
217 for i in $(seq 10); do
218 if checkinternet; then
227 # apply keybpard layout
228 if iconf layout; then
229 setxkbmap -layout "$(iconf layout)"
231 CURLOCALE=$(locale | grep LANG | sed 's/.*=\(.*\)\..*/\1/')
237 echo "no keyboard layout found for your locale"
243 if iconf mousespeed; then
244 echo "setting mousespeed"
245 instantmouse s "$(iconf mousespeed)"
248 if iconf -i reversemouse; then
254 if ! iconf -i noconky; then
255 shuf /usr/share/instantwidgets/tooltips.txt | head -1 >~/.cache/tooltip
256 conky -c /usr/share/instantwidgets/tooltips.conf &
260 echo "live session detected"
263 echo "disabling compositing for qxl graphics"
264 if lshw -c video | grep -i 'qxl' || xrandr | grep -i '^qxl'; then
268 sudo systemctl start NetworkManager
271 iconf -i wifiapplet 1
272 instantwallpaper set /usr/share/instantwallpaper/defaultphoto.png
273 conky -c /usr/share/instantwidgets/install.conf &
276 if ! pgrep python; then
284 # make built in status optional
285 if ! iconf -i nostatus; then
286 source /usr/bin/instantstatus &
290 HEIGHT=$(iconf max | grep -o '[0-9]*$')
291 WIDTH=$(iconf max | grep -o '^[0-9]*')
292 RESOLUTION="$((HEIGHT * WIDTH))"
293 DPIMESSAGE="HiDpi settings can be found in settings->display->dpi"
294 if ! imenu -C <<<"high resolution display detected
295 would you like to enable HiDpi?"; then
296 if imenu -c "ask again next time?"; then
300 imenu -m "$DPIMESSAGE"
304 DPI=$(imenu -i 'enter dpi (default is 96)')
305 while ! [ "$DPI" -eq "$DPI" ] || [ "$DPI" -gt 500 ] || [ "$DPI" -lt "20" ]; do
306 imenu -m "please enter a number between 20 and 500 (default is 96), enter q to skip hidpi"
307 DPI=$(imenu -i 'enter dpi (default is 96)')
308 if grep -q 'q' <<<"$DPI"; then
309 imenu -m "$DPIMESSAGE"
318 imenu -m "a restart is needed to globally apply dpi"
322 if ! iconf -i nohidpi && iconf max; then
323 if [ "$RESOLUTION" -gt 8294000 ]; then
329 if iconf -i potato || iconf -i nocompositing; then
330 echo "compositing disabled"
340 xfce4-power-manager &
342 # auto open menu when connecting/disconnecting monitor
343 if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
345 if nvidia-xconfig --query-gpu-info; then
346 DISPLAYCOUNT="$(nvidia-xconfig --query-gpu-info | grep -oi 'number of dis.*' | grep -o '[0-9]*')"
348 DISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
351 if [ "$DISPLAYCOUNT" -eq "$DISPLAYCOUNT" ]; then
353 NEWDISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
354 if ! [ "$DISPLAYCOUNT" = "$NEWDISPLAYCOUNT" ]; then
355 notify-send "display changed"
356 echo "displays changed"
357 if [ "$NEWDISPLAYCOUNT" -gt 1 ]; then
359 echo "multi monitor setup"
363 DISPLAYCOUNT="$NEWDISPLAYCOUNT"
369 echo "error detecting display count"
374 if iconf -b welcome; then
378 # prompt to fix configuration if installed from the AUR
379 if ! iconf -i norootinstall && ! islive; then
380 if ! command -v imenu || ! command -v instantmenu; then
381 notify-send "please install instantmenu and imenu"
383 if ! [ -e /opt/instantos/rootinstall ]; then
384 imenu -m "instantOS is missing some configuration"
385 while ! [ -e /tmp/rootskip ]; do
386 if imenu -c "would you like to fix that?"; then
387 touch /tmp/topinstall
388 instantsudo bash -c "instantutils root"
391 if imenu -c "Are you sure? this will prevent parts of instantOS from functioning correctly"; then
401 TODAY="$(date '+%d%m')"
402 OTHERTODAY="$(iconf today)"
404 if [ -z "$OTHERTODAY" ]; then
405 iconf today "$(date '+%d%m')"
406 OTHERTODAY="$(iconf today)"
409 if ! [ "$TODAY" = "$OTHERTODAY" ]; then
410 iconf today "$(date '+%d%m')"
411 echo "running daily routine"
415 # displays message user opens the terminal for the first time
416 if ! iconf -i nohelp; then
417 if ! grep -q 'instantterminalhelp' ~/.zshrc; then
418 echo '[[ $- == *i* ]] && instantterminalhelp' >>~/.zshrc
423 [ -n "$2" ] || return
424 iconf -i "$1" || return
428 # run command if iconf option is set
430 if iconf -i "$1"; then
436 if iconf savebright; then
437 export NOBRIGHTMESSAGE=true
438 /usr/share/instantassist/utils/b.sh 2 "$(iconf savebright)"
441 confkey highfps "super+alt+shift+d"
442 confkey noanimations "super+alt+shift+s"
444 if iconf -i alttab; then
445 instantwmctrl alttab 1
447 instantwmctrl alttab 0
451 confcommand desktopicons rox --pinboard Default
453 confcommand udiskie udiskie -t
455 confcommand clipmanager clipmenud
457 # user declared autostart
458 if [ -e ~/.config/instantos/autostart.sh ]; then
459 bash ~/.config/instantos/autostart.sh
463 if ! iconf -i noupdates && [ -z "$ISLIVE" ]; then
465 if checkinternet; then
468 if command -v checkinternet; then
471 if checkinternet; then
480 # start processes that need to be kept running
483 if iconf -i wifiapplet && ! pgrep nm-applet; then
484 echo "starting bluetooth applet"
488 if iconf -i bluetoothapplet && ! pgrep blueman-applet; then
489 echo "starting bluetooth applet"
493 if iconf -i alttab && ! pgrep alttab; then
494 alttab -fg "#ffffff" -bg "#292F3A" -frame "#5293E1" -d 0 -s 1 -t 128x150 -i 127x64 -w 1 -vp pointer &