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