-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgkeys.sh
More file actions
executable file
·49 lines (44 loc) · 1.21 KB
/
Copy pathpgkeys.sh
File metadata and controls
executable file
·49 lines (44 loc) · 1.21 KB
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
#!/bin/bash
# Toggle a swap of the PageUp/PageDown keys with Home/End (X11 / xmodmap).
# PageUp <-> Home
# PageDown <-> End
#
# Usage:
# togglepgkeys.sh toggle based on current state
# togglepgkeys.sh on force the swap on
# togglepgkeys.sh off restore defaults
if [ "$XDG_SESSION_TYPE" != "x11" ]; then
echo "error: requires an X11 session (xmodmap has no effect on Wayland)." >&2
exit 1
fi
swap_on() {
xmodmap -e "keycode 112 = Home" \
-e "keycode 117 = End" \
-e "keycode 110 = Prior" \
-e "keycode 115 = Next"
echo "PageUp/PageDown <-> Home/End swap: ON."
}
swap_off() {
xmodmap -e "keycode 112 = Prior" \
-e "keycode 117 = Next" \
-e "keycode 110 = Home" \
-e "keycode 115 = End"
echo "PageUp/PageDown <-> Home/End swap: OFF (defaults restored)."
}
case "$1" in
on) swap_on ;;
off) swap_off ;;
"")
# No argument: detect state from keycode 112 (physical PageUp).
current=$(xmodmap -pke | awk '$1=="keycode" && $2==112 {print $4}')
if [ "$current" = "Home" ]; then
swap_off
else
swap_on
fi
;;
*)
echo "usage: $0 [on|off] (no argument = toggle)" >&2
exit 1
;;
esac