2024-06-24 19:19:50 +02:00
|
|
|
#!/bin/sh
|
2024-01-26 12:41:40 +01:00
|
|
|
|
|
|
|
MAP_DIR="${XDG_DATA_HOME}/xkb/compiled"
|
|
|
|
|
|
|
|
rotate() {
|
2024-06-03 10:21:34 +02:00
|
|
|
current="$(readlink keymap)"
|
|
|
|
for f in *; do
|
|
|
|
[ "$f" = "keymap" ] && continue
|
|
|
|
[ -z "$first" ] && first=$f
|
|
|
|
[ -n "$found" ] && break
|
|
|
|
[ "$f" = "$current" ] && found=1
|
|
|
|
f=
|
|
|
|
done
|
|
|
|
[ "$f" = "keymap" ] || [ -z "$f" ] && f=$first
|
|
|
|
ln -sf "$f" keymap
|
2023-07-14 17:59:32 +02:00
|
|
|
}
|
|
|
|
|
2024-01-26 12:41:40 +01:00
|
|
|
setmap() {
|
2024-06-03 10:21:34 +02:00
|
|
|
current=${1:-$(readlink keymap)}
|
|
|
|
xkbcomp "$current" "$DISPLAY" >/dev/null 2>&1 || return 1
|
|
|
|
xset r rate 300 50
|
|
|
|
xset -q | grep -q "Caps Lock:\s*on" && xdotool key Caps_Lock
|
|
|
|
killall xcape 2>/dev/null
|
|
|
|
xcape -e 'Super_L=Escape'
|
|
|
|
$notifier -h string:x-dunst-stack-tag:"remaps" \
|
|
|
|
" Keymap set" "Layout: $current"
|
2023-07-14 17:59:32 +02:00
|
|
|
}
|
|
|
|
|
2024-01-26 12:41:40 +01:00
|
|
|
cd "$MAP_DIR" || return 1
|
|
|
|
notifier="notify-send"
|
2024-01-26 13:25:17 +01:00
|
|
|
|
2024-01-27 19:06:01 +01:00
|
|
|
while getopts "rqdls:" opt; do
|
2024-06-03 10:21:34 +02:00
|
|
|
case $opt in
|
|
|
|
d)
|
|
|
|
setmap
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
q) notifier=":" ;;
|
|
|
|
s)
|
|
|
|
setmap "$OPTARG"
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
l)
|
|
|
|
find . -type f -printf "%f\n"
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
2024-01-27 18:44:50 +01:00
|
|
|
done
|
2024-01-27 19:06:01 +01:00
|
|
|
|
|
|
|
rotate
|
|
|
|
setmap
|