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