fix vpn host naming
[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 type=model01
26
27 case $1 in
28 l) type=laptop ;;
29 k) type=kinesis ;;
30 m) type=model01 ;;
31 esac
32
33 #set -x
34 mi() {
35 xinput --get-feedbacks "$1" | grep "threshold"
36 xinput --get-feedbacks "$1" | grep "accelNum\|accelDenom"
37 xinput --list-props "$1" | grep "Device Accel Profile\|Device Accel Constant Deceleration\|Device Accel Velocity Scaling"
38 }
39 ms() {
40 xinput --set-ptr-feedback "$1" $2 ${3%/*} ${3#*/}
41 xinput --set-prop "$1" 'Device Accel Profile' $4
42 xinput --set-prop "$1" 'Device Accel Constant Deceleration' $5
43 xinput --set-prop "$1" 'Device Accel Velocity Scaling' $6
44 mi "$1"
45 }
46 set_device_id() {
47 if [[ $2 ]] && $2; then
48 cmd="tail -n1"
49 else
50 cmd="head -n1"
51 fi
52 if device_id=$(xinput --list | grep "$1" | $cmd); then
53 device_id=${device_id##*id=}
54 device_id=${device_id%%[[:space:]]*}
55 echo "2:$2 device_id=$device_id"
56 else
57 return 1
58 fi
59 }
60
61 # default via xset q is 660 25. (delay for autorepeat, repeat rate)
62 # was at 200 13, but while learning to use keyboardio, i hold keys a bit longer sometimes.
63 xset r rate 400 13 # decrease rate delay
64
65 if set_device_id "SteelSeries World of Warcraft MMO Gaming Mouse"; then
66 ms "$device_id" 100 1000/1 7 4 1
67
68 # under the new "improved" libinput, the mouse speed/accel has
69 # changed all around and is much more limited.
70 # Other xinput commands will fail and this will succeed.
71 xinput --set-prop "$device_id" "libinput Accel Speed" '.8'
72 fi
73
74 # todo, differentiate for work pc
75 #/a/bin/radl
76
77 case $type in
78 model01)
79 # original saved with: xkbcomp $DISPLAY /a/c/flidas-2017-12.xkb
80 xkbcomp /a/c/model01.xkb $DISPLAY
81 . /a/bin/bash_unpublished/duplicity-gpg-agent-setup
82 ;;
83 laptop)
84 xkbcomp /a/c/x2.xkb $DISPLAY
85
86 ;;
87 esac
88
89 # for desktop and htpc
90 if set_device_id "Logitech Unifying Device"; then
91 xinput --set-prop "$device_id" 'Evdev Middle Button Emulation' 1
92 fi
93
94
95 set +x
96 exit 0