minor improvements
[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 #ms "$device_id" 1 7/2 2 2.5 2
73
74 # makes it compatible with what windows sends using synergy
75 # commented out because i never expect to use windows again
76 #xinput --set-button-map "$device_id" 1 2 3 4 5 6 7 6 7 10 11 12 13 14 15
77
78 # under the new "improved" libinput, the mouse speed/accel has
79 # changed all around and is much more limited.
80 # Other xinput commands will fail and this will succeed.
81 xinput --set-prop "$device_id" "libinput Accel Speed" '.8'
82 fi
83
84 case $type in
85 model01)
86 xkbcomp /a/c/model01.xkb $DISPLAY
87 ;;
88 laptop)
89 # original saved with: xkbcomp $DISPLAY /a/c/stretch-11-2016.xkb
90 xkbcomp /a/c/x2.xkb $DISPLAY
91 xkbset -m # remove mouse keys
92
93 ;;
94 kinesis)
95 # todo, differentiate for work pc
96 #/a/bin/radl
97 if [[ -z $DISPLAY ]]; then
98 echo "error. empty DISPLAY var" >> /a/gdm-keyboard-error.log
99 else
100 xkbcomp /a/c/.Xkeymap $DISPLAY
101
102 xkbset m # setup mouse keys, which I have altered
103
104 xkbset exp =m # stop mousekeys expiring after a timeout
105
106 cd / # so xbindkeys does not hold open mountpoints
107 killall xbindkeys # having some lag, thinking this might help.
108 xbindkeys # configured to grab left and right scroll button presses
109 fi
110
111 kinesis2=false
112 #right scroll wheel, change from button 4 & 5 to 13 and 14.
113 # also changes the middle click to 12, even though I'm not using it anymore
114 if set_device_id "04d9:048e"; then
115 xinput --set-button-map "$device_id" 1 12 3 13 14 6 7
116 else
117 kinesis2=true # if we are using the 2nd kinesis which has different device ids
118 fi
119 if $kinesis2 && set_device_id "USB OPTICAL MOUSE" $k2flip; then
120 xinput --set-button-map "$device_id" 1 12 3 14 13 6 7
121 fi
122
123
124
125 ms 'Kensington Kensington Slimblade Trackball' 100 4000/1 7 6.5 1.5
126 xinput --set-button-map 'Kensington Kensington Slimblade Trackball' 0 0 0 4 5 6 7 0 9 10 11 12
127
128 # razer naga middle mouse stopped working. it's settings were:
129 #ms "$device_id" 100 1000/1 7 4 1
130
131
132
133 # disable the mouse movements mouse wheel
134 if $kinesis2; then
135 if set_device_id "USB OPTICAL MOUSE" $k2inorder; then
136 xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
137 # 12 is to effectively disable the middle click button
138 xinput --set-button-map "$device_id" 1 12 3 11 10 6 7
139 fi
140 else
141 if set_device_id "USB Optical Mouse"; then
142 xinput --set-prop "$device_id" 'Device Accel Constant Deceleration' 10000
143 # 12 is to effectively disable the middle click button
144 xinput --set-button-map "$device_id" 1 12 3 10 11 6 7
145 fi
146 fi
147
148 . /a/bin/bash_unpublished/duplicity-gpg-agent-setup
149 ;;
150 esac
151
152 # for desktop and htpc
153 if set_device_id "Logitech Unifying Device"; then
154 xinput --set-prop "$device_id" 'Evdev Middle Button Emulation' 1
155 fi
156
157 #ms 'Kensington Kensington Slimblade Trackball' 1 7/2 2 4 5 = 2.01
158 # ms 9 10 20/1 6 4 .2
159 #ms 9 10 35/1 6 5 .2 = 1.82
160 #ms 9 10 1200/1 7 5 .2 = 1.82 after a practice round
161 #
162 #ms 9 10 140/1 6 7 .1 = 2.0 after a practice round.
163 #feels like the slow is finally too slow, and fast too fast
164 # ms 9 10 50/1 6 6 .2 = 1.83 after
165 # ms 9 10 90/1 6 6 .1 = 1.86
166 #ms 9 10 3000/1 7 6 .1 = 1.81
167 #ms 9 1 15/1 3 6 3 = 2.0
168 #ms 9 1 10/1 3 4 2 = 1.91
169 #ms 9 1 8/1 3 5 4 = 1.98
170 #ms 9 1 10/2 2 5 2.5 = 1.99
171 #ms 9 100 3000/1 7 5 1 = 1.86
172 #ms 9 100 1500/1 7 5 1.5 = 1.87
173 #ms 9 100 2200/1 7 6 1.5 = 1.81
174 #ms 9 100 2200/1 7 5 1.5 = 1.83
175 #ms 9 100 3000/1 7 6 1.5 = 1.88
176 #ms 9 1 100/1 4 6 15 = 1.85
177 #ms 9 100 3000/1 7 7 1.5 = 1.85, but had a 1.76 on first try...
178 # ms 9 100 3500/1 7 7 1.5 = 1.73, 1.68 a1 1.74, 1.83, 1.75, 1.78, 1.76
179 # ms 9 100 4000/1 7 7 1.5 = 1.80
180 # ms 9 100 4000/1 7 8 1.5 = 1.78
181 # ms 9 100 4000/1 7 8 1.8 = 1.88
182 # ms 9 100 4800/1 7 8 1.5 = 1.85
183 # 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
184 # new day
185 # ms 9 100 3500/1 7 7 1.5 = 1.92
186 # ms 9 1 7/2 2 5 5 = 1.9
187 # ms 9 100 3500/1 7 7 1.5 = 1.62
188 # felt like having it a bit faster for a while, but switched back
189 #ms 'Kensington Kensington Slimblade Trackball' 100 3500/1 7 5 1.5
190
191
192 #set +x
193 exit 0