-
Notifications
You must be signed in to change notification settings - Fork 0
/
remaps
executable file
·94 lines (78 loc) · 1.66 KB
/
remaps
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
PROG=$(basename "$0")
LAYOUT="us"
DEPS=(setxkbmap xset)
VARIANT="altgr-intl"
SETXKB=$(which setxkbmap)
ICON=""
function logme {
printf "%s: %s\n" "$PROG" "$1"
}
function log_exit {
printf "%s: %s\n" "$PROG" "$1" >&2
exit 1
}
function set_normal_rules {
local retcode
$SETXKB -rules evdev \
-model evdev \
-layout "${LAYOUT}" \
-variant "${VARIANT}" \
-option caps:swapescape \
-option compose:ralt
retcode=$?
if [[ $retcode -ne 0 ]]; then
log_exit "setxkbmap failed"
fi
}
function set_rule_esc_and_ctrl {
local retcode
$SETXKB -rules evdev \
-model evdev \
-layout "${LAYOUT}" \
-variant "${VARIANT}" \
-option ctrl:nocaps
retcode=$?
if [[ $retcode -ne 0 ]]; then
log_exit "setxkbmap failed"
fi
xcape -e 'Control_L=Escape'
}
function set_rate {
xset r rate 200 50
# xset r rate 300 50
# xset r rate 250 44
}
function get_xkbmap {
local current
current=$($SETXKB -query | grep "layout\|variant" | awk '{print $2}' | paste -sd "_")
echo "$current"
}
function bar_output {
local current
current=$(get_xkbmap)
printf "%b %s" "$ICON" "$current"
}
function main {
for dep in "${DEPS[@]}"; do
if ! command -v "${dep}" >/dev/null; then
log_exit "'${dep}' not found"
fi
done
logme "setting -> ${LAYOUT}_$VARIANT"
case "$1" in
alternative)
set_rule_esc_and_ctrl
set_rate
;;
bar) bar_output ;;
*)
set_normal_rules
set_rate
;;
esac
set_normal_rules
set_rate
exit 0
}
main "$@"