OSDN Git Service

Merge pull request #81 from bob8677/master
[instantos/instantOS.git] / autostart.sh
index 1379e53..578627e 100755 (executable)
@@ -39,8 +39,7 @@ else
 fi
 
 cd
-if ! iconf -r keepdotfiles && ! iconf -i nodotfiles
-then
+if ! iconf -r keepdotfiles && ! iconf -i nodotfiles; then
     command -v instantdotfiles && instantdotfiles
 fi
 
@@ -73,6 +72,20 @@ islive() {
     fi
 }
 
+applymouse() {
+    # read cursor speed
+    if iconf mousespeed; then
+        echo "setting mousespeed"
+        instantmouse s "$(iconf mousespeed)"
+    fi
+
+    if iconf -i reversemouse; then
+        instantmouse r 1
+    else
+        instantmouse r 0
+    fi
+}
+
 # optionally disable status bar
 if iconf -i nobar; then
     NMON=$(iconf names | wc -l)
@@ -228,31 +241,14 @@ if ! islive; then
     fi &
 
     # apply keybpard layout
-    if iconf layout; then
-        setxkbmap -layout "$(iconf layout)"
-    else
-        CURLOCALE=$(locale | grep LANG | sed 's/.*=\(.*\)\..*/\1/')
-        case "$CURLOCALE" in
-        de_DE)
-            setxkbmap -layout de
-            ;;
-        *)
-            echo "no keyboard layout found for your locale"
-            ;;
-        esac
-    fi
-
-    # read cursor speed
-    if iconf mousespeed; then
-        echo "setting mousespeed"
-        instantmouse s "$(iconf mousespeed)"
+    if ! iconf layout; then
+        if iconf -r layout; then
+            iconf layout "$(iconf -r layout)"
+        fi
     fi
 
-    if iconf -i reversemouse; then
-        instantmouse r 1
-    else
-        instantmouse r 0
-    fi
+    KEYLAYOUT="$(iconf layout:us)"
+    setxkbmap -layout "$KEYLAYOUT"
 
     if ! iconf -i noconky; then
         shuf /usr/share/instantwidgets/tooltips.txt | head -1 >~/.cache/tooltip
@@ -335,11 +331,6 @@ else
     ipicom &
 fi
 
-while :; do
-    lxpolkit
-    sleep 10
-done &
-
 xfce4-power-manager &
 
 # auto open menu when connecting/disconnecting monitor
@@ -445,9 +436,9 @@ confkey highfps "super+alt+shift+d"
 confkey noanimations "super+alt+shift+s"
 
 if iconf -i alttab; then
-    instantwmctrl alttab 1
+    instantwmctrl alttab 3
 else
-    instantwmctrl alttab 0
+    instantwmctrl alttab 1
 fi
 
 # desktop icons
@@ -480,14 +471,28 @@ if ! iconf -i noupdates && [ -z "$ISLIVE" ]; then
     fi
 fi &
 
+# needed for things like the pamac auth prompt
+while :; do
+    lxpolkit
+    sleep 2
+done &
+
 # start processes that need to be kept running
 while :; do
-    sleep 10
+    sleep 2
+    # check if new device has been plugged in
+    XINPUTSUM="$(xinput | md5sum)"
+    if ! [ "$OLDXSUM" = "$XINPUTSUM" ]; then
+        OLDXSUM="$XINPUTSUM"
+        instantmouse gen
+        applymouse
+    fi
+    sleep 2
     if iconf -i wifiapplet && ! pgrep nm-applet; then
-        echo "starting bluetooth applet"
+        echo "starting wifi applet"
         nm-applet &
     fi
-
+    sleep 2
     if iconf -i bluetoothapplet && ! pgrep blueman-applet; then
         echo "starting bluetooth applet"
         blueman-applet &
@@ -496,6 +501,6 @@ while :; do
     if iconf -i alttab && ! pgrep alttab; then
         alttab -fg "#ffffff" -bg "#292F3A" -frame "#5293E1" -d 0 -s 1 -t 128x150 -i 127x64 -w 1 -vp pointer &
     fi
-    sleep 2m
 
+    sleep 1m
 done