fix mistake from recent commit
[distro-setup] / input-setup
1 #!/bin/bash -l
2 set -x
3 # Copyright (C) 2016 Ian Kelling
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # set to oppsite if the order is flipped.
18 k2flip=true
19 if $k2flip; then
20 k2inorder=false
21 else
22 k2inorder=true
23 fi
24
25 case $HOSTNAME in
26 some_x200_laptop) type=laptop ;;
27 hosts_with_keyboards_attached) type=kinesis ;;
28 esac
29
30
31
32 case $1 in
33 l) type=laptop ;;
34 k) type=kinesis ;;
35 m) type=model01 ;;
36 esac
37
38 #set -x
39 mi() {
40 xinput --get-feedbacks "$1" | grep "threshold"
41 xinput --get-feedbacks "$1" | grep "accelNum\|accelDenom"
42 xinput --list-props "$1" | grep "Device Accel Profile\|Device Accel Constant Deceleration\|Device Accel Velocity Scaling"
43 }
44 ms() {
45 xinput --set-ptr-feedback "$1" $2 ${3%/*} ${3#*/}
46 xinput --set-prop "$1" 'Device Accel Profile' $4
47 xinput --set-prop "$1" 'Device Accel Constant Deceleration' $5
48 xinput --set-prop "$1" 'Device Accel Velocity Scaling' $6
49 mi "$1"
50 }
51 set_device_id() {
52 if [[ $2 ]] && $2; then
53 cmd="tail -n1"
54 else
55 cmd="head -n1"
56 fi
57 if device_id=$(xinput --list | grep "$1" | $cmd); then
58 device_id=${device_id##*id=}
59 device_id=${device_id%%[[:space:]]*}
60 echo "2:$2 device_id=$device_id"
61 else
62 return 1
63 fi
64 }
65
66 # default via xset q is 660 25. (delay for autorepeat, repeat rate)
67 # was at 200 13, but while learning to use keyboardio, i hold keys a bit longer sometimes.
68 xset r rate 400 13 # decrease rate delay
69
70 if set_device_id "SteelSeries World of Warcraft MMO Gaming Mouse"; then
71 ms "$device_id" 100 1000/1 7 4 1
72
73 # under the new "improved" libinput, the mouse speed/accel has
74 # changed all around and is much more limited.
75 # Other xinput commands will fail and this will succeed.
76 xinput --set-prop "$device_id" "libinput Accel Speed" '.8'
77 fi
78
79 # todo, differentiate for work pc
80 #/a/bin/radl
81
82 case $type in
83 model01)
84 xkbcomp /a/c/model01.xkb $DISPLAY
85 . /a/bin/bash_unpublished/duplicity-gpg-agent-setup
86 ;;
87 laptop)
88 # original saved with: xkbcomp $DISPLAY /a/c/stretch-11-2016.xkb
89 xkbcomp /a/c/x2.xkb $DISPLAY
90
91 ;;
92 esac
93
94 # for desktop and htpc
95 if set_device_id "Logitech Unifying Device"; then
96 xinput --set-prop "$device_id" 'Evdev Middle Button Emulation' 1
97 fi
98
99
100 set +x
101 exit 0