1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/sh
# This script is called on startup to remap keys.
xset s off -dpms
# Decrease key repeat delay to 200ms and increase key repeat rate to 50 per second.
xset r rate 200 50
# Map the caps lock key to control, and map the menu key to right super.
xinput list | grep 'id=' | while read -r line; do
keyboard=$(echo "$line" | grep -i 'keyboard.*id.*keyboard' | sed 's/.*id=\([0-9]\+\).*/\1/')
mouse=$(echo "$line" | grep -i '.*id.*pointer' | sed 's/.*id=\([0-9]\+\).*/\1/')
[ -z "$keyboard" ] || {
case "$(echo "$line" | grep -oE '.*id=' | sed 's/ id=.*//')" in
*"Lite-On Tech Lenovo USB Travel Keyboard with Ultra Nav"*)
setxkbmap -device "$keyboard" -option
setxkbmap -device "$keyboard" -option caps:ctrl_modifier,ctrl:swap_lwin_lctl
;;
*"Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint"* | *"AT Translated Set 2 keyboard"*)
setxkbmap -device "$keyboard" -option
setxkbmap -device "$keyboard" -option caps:ctrl_modifier,altwin:menu_win,altwin:swap_lalt_lwin
;;
*"Magic keyboard"*)
setxkbmap -device "$keyboard" -option
setxkbmap -device "$keyboard" -option caps:ctrl_modifier
;;
*"HHKB"*)
setxkbmap -device "$keyboard" -option
setxkbmap -device "$keyboard" -option altwin:menu_win
;;
*"Glove80"*)
setxkbmap -device "$keyboard" -option
;;
*)
setxkbmap -device "$keyboard" -option
setxkbmap -device "$keyboard" -option caps:ctrl_modifier,altwin:menu_win
;;
esac
}
[ -z "$mouse" ] || {
case "$(echo "$line" | grep -oE '.*id=' | sed 's/ id=.*//')" in
*"Apple Inc. Magic Trackpad"*)
xinput set-prop "$mouse" "libinput Tapping Enabled" 0
;;
*"SynPS/2 Synaptics TouchPad"*)
xinput set-prop "$mouse" "libinput Tapping Enabled" 0
;;
*"Lite-On Tech Lenovo USB Travel Keyboard with Ultra Nav Mouse"*)
[ -z "$1" ] && xinput set-prop "$mouse" "Coordinate Transformation Matrix" 5, 0, 0, 0, 5, 0, 0, 0, 1 || xinput set-prop "$mouse" "Coordinate Transformation Matrix" $1, 0, 0, 0, $1, 0, 0, 0, 1
xinput set-prop "$mouse" "libinput Scroll Method Enabled" 0, 0, 1
;;
*"Logitech USB Receiver"*)
[ -z "$1" ] && xinput set-prop "$mouse" "Coordinate Transformation Matrix" 3, 0, 0, 0, 3, 0, 0, 0, 1 || xinput set-prop "$mouse" "Coordinate Transformation Matrix" $1, 0, 0, 0, $1, 0, 0, 0, 1
;;
*"TPPS/2 IBM TrackPoint"*)
[ -z "$1" ] && xinput set-prop "$mouse" "Coordinate Transformation Matrix" 1, 0, 0, 0, 1, 0, 0, 0, 1 || xinput set-prop "$mouse" "Coordinate Transformation Matrix" $1, 0, 0, 0, $1, 0, 0, 0, 1
;;
*"Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint"*)
[ -z "$1" ] && xinput set-prop "$mouse" "Coordinate Transformation Matrix" 3, 0, 0, 0, 3, 0, 0, 0, 1 || xinput set-prop "$mouse" "Coordinate Transformation Matrix" $1, 0, 0, 0, $1, 0, 0, 0, 1
;;
*"Glove80 Mouse"*)
[ -z "$1" ] && xinput set-prop "$mouse" "Coordinate Transformation Matrix" 2, 0, 0, 0, 2, 0, 0, 0, 1 || xinput set-prop "$mouse" "Coordinate Transformation Matrix" $1, 0, 0, 0, $1, 0, 0, 0, 1
;;
esac
}
done
# When left control, caps lock, or Super_L is pressed only once, treat it as escape.
killall xcape 2>/dev/null
xcape -e 'Caps_Lock=Escape;Control_L=Escape' #;Super_L=Escape'
# Turn off caps lock if on since there is no longer a key for it.
xset -q | grep -q "Caps Lock:\s*on" && xdotool key Caps_Lock
|