1
0
Fork 0

rework keymapping

This commit is contained in:
Luca Bilke 2023-07-14 17:59:32 +02:00
parent 8be4d36eef
commit 9451dae84f
No known key found for this signature in database
GPG Key ID: 7B77C51E8C779E75
9 changed files with 5019 additions and 14 deletions

View File

@ -9,7 +9,7 @@ xwallpaper --zoom "${XDG_DATA_HOME:-$HOME/.local/share}/bg" &
start pipewire
start pipewire -c pipewire-pulse.conf
start wireplumber
start remaps
start remaps -qd
start checkup
start playerctld daemon
start picom

View File

@ -1,5 +1,5 @@
#!/bin/bash
while :; do
grep -qP -m1 '[^un]bind.+\/[^:]+\(usb\)' <(udevadm monitor -u -t seat -s input -s usb)
remaps
remaps -qd
done

View File

@ -1,17 +1,60 @@
#!/bin/sh
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"
}
DISPLAY=:0
XKBDIR="$XDG_CONFIG_HOME/X11/xkb"
XKBMAPFILE="$XKBDIR/keymap/$(hostname)"
[ -r "$XKBMAPFILE" ] || XKBMAPFILE="$XKBDIR/keymap/default"
xkbcomp -I"$XKBDIR" "$XKBMAPFILE" "${DISPLAY%%.*}" 1>/dev/null 2>&1
unset XKBDIR XKBMAPFILE
notify=true
while getopts dq flag; do
case "$flag" in
d)
setmap "$default"
return
;;
q) notify=false ;;
*) ;;
esac
done
rotatemap
xset r rate 300 50
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
killall xcape 2>/dev/null
xcape -e 'Super_L=Escape'
sleep 0.03
[ "$1" != "-n" ] && pkill -RTMIN+15 dwmblocks
# sleep 0.03
# [ "$1" != "-n" ] && pkill -RTMIN+15 dwmblocks

7
.local/share/xkb/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
for f in keymap/*; do
name="$(basename "$f")"
echo "--------------------------- Compiling $name ---------------------------"
xkbcomp -I. "$f" -xkb -o "compiled/${name}.xkb" -a -w4
# xkbcomp -I. "$f" -xkm -o "compiled/$(basename "$f").xkm"
done

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,6 @@ default xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+custom(dvorak)+inet(evdev)" };
xkb_symbols { include "pc+de(nodeadkeys)+inet(evdev)+level3(ralt_switch)+capslock(super)" };
xkb_geometry { include "pc(pc105)" };
};

View File

@ -0,0 +1,7 @@
default xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+custom(dvorak)+inet(evdev)+level3(ralt_switch)+capslock(super)" };
xkb_geometry { include "pc(pc105)" };
};

View File

@ -12,8 +12,4 @@ xkb_symbols "dvorak" {
key <AC10> { [s, S, ssharp ] };
key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
include "level3(ralt_switch)"
include "capslock(super)"
};