lots of fixes and improvements
[distro-setup] / input-setup
index 67444511e037323429d094e6c69f5e7dc41f1ca0..798748a282cc7e5be2e2a7924900572e2f1ec2f1 100755 (executable)
@@ -1,4 +1,39 @@
 #!/bin/bash -l
+set -x
+# Copyright (C) 2016 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# set to oppsite if the order is flipped.
+k2flip=false
+if $k2flip; then
+    k2inorder=false
+else
+    k2inorder=true
+fi
+
+case $HOSTNAME in
+    some_x200_laptop) type=laptop ;;
+    hosts_with_keyboards_attached) type=kinesis ;;
+esac
+
+
+
+case $1 in
+    l) type=laptop ;;
+    k) type=kinesis ;;
+esac
+
 #set -x
 mi() {
     xinput --get-feedbacks "$1" | grep "threshold"
@@ -13,16 +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
-    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
@@ -35,15 +82,24 @@ case $HOSTNAME in
             xkbset exp =m  # stop mousekeys expiring after a timeout
 
             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
@@ -65,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