move some stuff to frodo, rename user to iank, fixes
[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=false
19 if $k2flip; then
20 k2inorder=false
21 else
22 k2inorder=true
23 fi
24
25 case $HOSTNAME in
26 x2|tp) type=laptop ;;
27 treetowl*|iank-dev|frodo) type=kinesis ;;
28 esac
29
30
31
32 case $1 in
33 l) type=laptop ;;
34 k) type=kinesis ;;
35 esac
36
37 #set -x
38 mi() {
39 xinput --get-feedbacks "$1" | grep "threshold"
40 xinput --get-feedbacks "$1" | grep "accelNum\|accelDenom"
41 xinput --list-props "$1" | grep "Device Accel Profile\|Device Accel Constant Deceleration\|Device Accel Velocity Scaling"
42 }
43 ms() {
44 xinput --set-ptr-feedback "$1" $2 ${3%/*} ${3#*/}
45 xinput --set-prop "$1" 'Device Accel Profile' $4
46 xinput --set-prop "$1" 'Device Accel Constant Deceleration' $5
47 xinput --set-prop "$1" 'Device Accel Velocity Scaling' $6
48 mi "$1"
49 }
50 set_device_id() {
51 if [[ $2 ]] && $2; then
52 cmd="tail -n1"
53 else
54 cmd="head -n1"
55 fi
56 if device_id=$(xinput --list | grep "$1" | $cmd); then
57 device_id=${device_id##*id=}
58 device_id=${device_id%%[[:space:]]*}
59 echo "2:$2 device_id=$device_id"
60 else
61 return 1
62 fi
63 }
64
65 case $type in
66 laptop)
67 # original saved with: xkbcomp $DISPLAY /a/c/stretch-11-2016.xkb
68 xkbcomp /a/c/x2.xkb $DISPLAY
69 xkbset -m # remove mouse keys
70
71 ;;
72 kinesis)
73 # todo, differentiate for work pc
74 #/a/bin/radl
75 if [[ -z $DISPLAY ]]; then
76 echo "error. empty DISPLAY var" >> /a/gdm-keyboard-error.log
77 else
78 xkbcomp /a/c/.Xkeymap $DISPLAY
79
80 xkbset m # setup mouse keys, which I have altered
81
82 xkbset exp =m # stop mousekeys expiring after a timeout
83
84 xset r rate 200 13 # decrease rate delay
85 cd / # so xbindkeys does not hold open mountpoints
86 killall xbindkeys # having some lag, thinking this might help.
87 xbindkeys # configured to grab left and right scroll button presses
88 fi
89
90 kinesis2=false
91 #right scroll wheel, change from button 4 & 5 to 13 and 14.
92 # also changes the middle click to 12, even though I'm not using it anymore
93 if set_device_id "04d9:048e"; then
94 xinput --set-button-map "$device_id" 1 12 3 13 14 6 7
95 else
96 kinesis2=true # if we are using the 2nd kinesis which has different device ids
97 fi
98 if $kinesis2 && set_device_id "USB OPTICAL MOUSE" $k2flip; then
99 xinput --set-button-map "$device_id" 1 12 3 14 13 6 7
100 fi
101
102
103
104 ms 'Kensington Kensington Slimblade Trackball' 100 4000/1 7 6.5 1.5
105 xinput --set-button-map 'Kensington Kensington Slimblade Trackball' 0 0 0 4 5 6 7 0 9 10 11 12
106
107 # razer naga middle mouse stopped working. it's settings were:
108 #ms "$device_id" 100 1000/1 7 4 1
109
110 if set_device_id "SteelSeries World of Warcraft MMO Gaming Mouse"; then
111 ms "$device_id" 100 1000/1 7 4 1
112 #ms "$device_id" 1 7/2 2 2.5 2
113
114 # makes it compatible with what windows sends using synergy
115 xinput --set-button-map "$device_id" 1 2 3 4 5 6 7 6 7 10 11 12 13 14 15
116
117 # under the new "improved" libinput, the mouse speed/accel has
118 # changed all around and is much more limited.
119 # Other xinput commands will fail and this will succeed.
120 xinput --set-prop "$device_id" "libinput Accel Speed" '.8'
121 fi
122
123
124 # disable the mouse movements mouse wheel
125 if $kinesis2; then
126 if set_device_id "USB OPTICAL MOUSE" $k2inorder; then
127 xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
128 # 12 is to effectively disable the middle click button
129 xinput --set-button-map "$device_id" 1 12 3 11 10 6 7
130 fi
131 else
132 if set_device_id "USB Optical Mouse"; then
133 xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
134 # 12 is to effectively disable the middle click button
135 xinput --set-button-map "$device_id" 1 12 3 10 11 6 7
136 fi
137 fi
138
139 . /a/bin/bash_unpublished/duplicity-gpg-agent-setup
140 ;;
141 esac
142
143 # for desktop and htpc
144 set_device_id "Logitech Unifying Device"
145 xinput --set-prop "$device_id" 'Evdev Middle Button Emulation' 1
146
147
148 #ms 'Kensington Kensington Slimblade Trackball' 1 7/2 2 4 5 = 2.01
149 # ms 9 10 20/1 6 4 .2
150 #ms 9 10 35/1 6 5 .2 = 1.82
151 #ms 9 10 1200/1 7 5 .2 = 1.82 after a practice round
152 #
153 #ms 9 10 140/1 6 7 .1 = 2.0 after a practice round.
154 #feels like the slow is finally too slow, and fast too fast
155 # ms 9 10 50/1 6 6 .2 = 1.83 after
156 # ms 9 10 90/1 6 6 .1 = 1.86
157 #ms 9 10 3000/1 7 6 .1 = 1.81
158 #ms 9 1 15/1 3 6 3 = 2.0
159 #ms 9 1 10/1 3 4 2 = 1.91
160 #ms 9 1 8/1 3 5 4 = 1.98
161 #ms 9 1 10/2 2 5 2.5 = 1.99
162 #ms 9 100 3000/1 7 5 1 = 1.86
163 #ms 9 100 1500/1 7 5 1.5 = 1.87
164 #ms 9 100 2200/1 7 6 1.5 = 1.81
165 #ms 9 100 2200/1 7 5 1.5 = 1.83
166 #ms 9 100 3000/1 7 6 1.5 = 1.88
167 #ms 9 1 100/1 4 6 15 = 1.85
168 #ms 9 100 3000/1 7 7 1.5 = 1.85, but had a 1.76 on first try...
169 # ms 9 100 3500/1 7 7 1.5 = 1.73, 1.68 a1 1.74, 1.83, 1.75, 1.78, 1.76
170 # ms 9 100 4000/1 7 7 1.5 = 1.80
171 # ms 9 100 4000/1 7 8 1.5 = 1.78
172 # ms 9 100 4000/1 7 8 1.8 = 1.88
173 # ms 9 100 4800/1 7 8 1.5 = 1.85
174 # ms 9 100 4000/1 7 6.5 1.5 = 1.83. stickig with this, upped speeds a bit to make it more practical for normal windows
175 # new day
176 # ms 9 100 3500/1 7 7 1.5 = 1.92
177 # ms 9 1 7/2 2 5 5 = 1.9
178 # ms 9 100 3500/1 7 7 1.5 = 1.62
179 # felt like having it a bit faster for a while, but switched back
180 #ms 'Kensington Kensington Slimblade Trackball' 100 3500/1 7 5 1.5
181
182
183 #set +x