lots of updates
[distro-setup] / input-setup
index 5db66e9dd92f77a7f994b6bb594e106b9416f64f..4e2e66b2ca66db7323ff6c053db60edd40242cc9 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash -l
+set -x
 # Copyright (C) 2016 Ian Kelling
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# set to oppsite if the order is flipped.
+k2flip=true
+if $k2flip; then
+    k2inorder=false
+else
+    k2inorder=true
+fi
+
+case $HOSTNAME in
+    x2|tp) type=laptop ;;
+    treetowl*|iank-dev|frodo) type=kinesis ;;
+esac
+
+
+
+case $1 in
+    l) type=laptop ;;
+    k) type=kinesis ;;
+esac
+
 #set -x
 mi() {
     xinput --get-feedbacks "$1" | grep "threshold"
@@ -27,20 +48,28 @@ ms() {
     mi "$1"
 }
 set_device_id() {
-    if device_id=$(xinput --list | grep -m 1 "$1"); then
+    if [[ $2 ]] && $2; then
+        cmd="tail -n1"
+    else
+        cmd="head -n1"
+    fi
+    if device_id=$(xinput --list | grep "$1" | $cmd); then
         device_id=${device_id##*id=}
         device_id=${device_id%%[[:space:]]*}
+        echo "2:$2 device_id=$device_id"
     else
         return 1
     fi
 }
 
-case $HOSTNAME in
-       tp|x2)
-               # original saved with: xkbcomp $DISPLAY /a/c/stretch-11-2016.xkb
-               xkbcomp /a/c/x2.xkb $DISPLAY
-               ;;
-    treetowl*|iank-dev|frodo)
+case $type in
+    laptop)
+       # original saved with: xkbcomp $DISPLAY /a/c/stretch-11-2016.xkb
+       xkbcomp /a/c/x2.xkb $DISPLAY
+        xkbset -m # remove mouse keys
+
+       ;;
+    kinesis)
         # todo, differentiate for work pc
        #/a/bin/radl
         if [[ -z $DISPLAY ]]; then
@@ -54,16 +83,24 @@ case $HOSTNAME in
 
             xset r rate 200 13 # decrease rate delay
             cd / # so xbindkeys does not hold open mountpoints
+            killall xbindkeys # having some lag, thinking this might help.
             xbindkeys # configured to grab left and right scroll button presses
         fi
 
-
+        kinesis2=false
         #right scroll wheel, change from button 4 & 5 to 13 and 14.
         # also changes the middle click to 12, even though I'm not using it anymore
         if set_device_id "04d9:048e"; then
             xinput --set-button-map "$device_id" 1 12 3 13 14 6 7
+        else
+            kinesis2=true # if we are using the 2nd kinesis which has different device ids
+        fi
+        if $kinesis2 && set_device_id "USB OPTICAL MOUSE" $k2flip; then
+            xinput --set-button-map "$device_id" 1 12 3 14 13 6 7
         fi
 
+
+
         ms 'Kensington Kensington Slimblade Trackball' 100 4000/1 7 6.5 1.5
         xinput --set-button-map 'Kensington Kensington Slimblade Trackball' 0 0 0 4 5 6 7 0 9 10 11 12
 
@@ -84,15 +121,22 @@ case $HOSTNAME in
         fi
 
 
-        # disable the mouse movements of my mouse-wheel only mouse
-        if set_device_id "USB Optical Mouse"; then
-            xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
-            # 12 is to effectively disable the middle click button
-            xinput --set-button-map "$device_id" 1 12 3 10 11 6 7
+        # disable the mouse movements mouse wheel
+        if $kinesis2; then
+            if set_device_id "USB OPTICAL MOUSE" $k2inorder; then
+                xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
+                # 12 is to effectively disable the middle click button
+                xinput --set-button-map "$device_id" 1 12 3 11 10 6 7
+            fi
+        else
+            if set_device_id "USB Optical Mouse"; then
+                xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
+                # 12 is to effectively disable the middle click button
+                xinput --set-button-map "$device_id" 1 12 3 10 11 6 7
+            fi
         fi
-        /a/bin/bash_unpublished/gpg
-        ;;
-    frodo*)
+
+        . /a/bin/bash_unpublished/duplicity-gpg-agent-setup
         ;;
 esac