1
0
Fork 0

fix remaps script

This commit is contained in:
Luca Bilke 2024-05-24 23:55:34 +02:00
parent 30176a8a6b
commit 68444d212a
2 changed files with 36 additions and 35 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.config/zsh/completions/_kube
.config/zsh/configs/host-setup
.local/share/service
.local/share/xkb/compiled/keymap

View file

@ -1,51 +1,51 @@
#!/bin/sh
MAP_DIR="${XDG_DATA_HOME}/xkb/compiled"
MAP_DIR="${STOW_DIR}/${DOTS_PACKAGE}/.local/share/xkb/compiled"
rotate() {
current="$(readlink keymap)"
for f in *; do
readlink "$f" >/dev/null && continue
[ -z "$first" ] && first=$f
[ -n "$found" ] && break
[ "$f" = "$current" ] && found=1
f=
done
[ -h "$f" ] || [ -z "$f" ] && f=$first
ln -sf "$f" keymap
current="$(readlink keymap)"
for f in *; do
readlink "$f" >/dev/null && continue
[ -z "$first" ] && first=$f
[ -n "$found" ] && break
[ "$f" = "$current" ] && found=1
f=
done
[ -h "$f" ] || [ -z "$f" ] && f=$first
ln -sf "$f" keymap
}
setmap() {
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"
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"
}
cd "$MAP_DIR" || return 1
notifier="notify-send"
while getopts "rqdls:" opt; do
case $opt in
d)
setmap
exit
;;
q) notifier=":" ;;
s)
setmap "$OPTARG"
exit
;;
l)
find . -type f -printf "%f\n"
exit
;;
*) ;;
esac
case $opt in
d)
setmap
exit
;;
q) notifier=":" ;;
s)
setmap "$OPTARG"
exit
;;
l)
find . -type f -printf "%f\n"
exit
;;
*) ;;
esac
done
rotate