2022-07-04 21:36:33 +02:00
|
|
|
#!/bin/sh
|
2022-09-17 00:06:31 +02:00
|
|
|
|
2023-07-14 17:59:32 +02:00
|
|
|
statefile="/tmp/current-keymap"
|
|
|
|
default="${XDG_DATA_HOME}/xkb/compiled/dvorak.xkb"
|
|
|
|
|
|
|
|
[ -r $statefile ] && current=$(cat $statefile) || current=""
|
|
|
|
|
|
|
|
setmap() {
|
|
|
|
xkbcomp "$1" "$DISPLAY"
|
|
|
|
if $notify; then
|
|
|
|
notify-send -h string:x-dunst-stack-tag:"remaps" \
|
|
|
|
" Keymap set" "Layout: $(xkbcomp :0 - | grep -oP "(?<=pc[_+])([^_+]+)(?=[_+])" | tr "(" " " | head -c -2)"
|
|
|
|
fi
|
|
|
|
echo "$1" >"$statefile"
|
|
|
|
}
|
|
|
|
|
|
|
|
rotatemap() {
|
|
|
|
if [ "$current" = "" ]; then
|
|
|
|
setmap "$default"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
currentfound=false
|
|
|
|
first=""
|
|
|
|
for f in "${XDG_DATA_HOME}/xkb/compiled/"*; do
|
|
|
|
if [ "$first" = "" ]; then
|
|
|
|
first=$f
|
|
|
|
fi
|
|
|
|
if $currentfound; then
|
|
|
|
setmap "$f"
|
|
|
|
return
|
|
|
|
elif [ "$f" = "$current" ]; then
|
|
|
|
currentfound=true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
setmap "$first"
|
|
|
|
}
|
|
|
|
|
2023-03-18 13:34:06 +01:00
|
|
|
DISPLAY=:0
|
|
|
|
|
2023-07-14 17:59:32 +02:00
|
|
|
notify=true
|
|
|
|
while getopts dq flag; do
|
|
|
|
case "$flag" in
|
|
|
|
d)
|
|
|
|
setmap "$default"
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
q) notify=false ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
rotatemap
|
2022-10-27 09:36:59 +02:00
|
|
|
|
2022-07-04 21:36:33 +02:00
|
|
|
xset r rate 300 50
|
2023-03-17 16:59:59 +01:00
|
|
|
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
|
2023-02-07 17:19:53 +01:00
|
|
|
killall xcape 2>/dev/null
|
|
|
|
xcape -e 'Super_L=Escape'
|
2023-03-17 16:59:59 +01:00
|
|
|
|
2023-07-14 17:59:32 +02:00
|
|
|
# sleep 0.03
|
|
|
|
# [ "$1" != "-n" ] && pkill -RTMIN+15 dwmblocks
|