1
0
Fork 0

new way of handling remaps

This commit is contained in:
Luca Bilke 2023-03-17 16:59:59 +01:00
parent a0abbe52b1
commit a43305d350
10 changed files with 113 additions and 1504 deletions

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+us(dvorak)+inet(evdev)+custom(caps_mod4)+custom(ralt_mod3)+custom(group2_dvorak)" };
xkb_geometry { include "pc(pc105)" };
};

View file

@ -0,0 +1,52 @@
// capslock as mod4
partial modifier_keys
xkb_symbols "caps_mod4" {
key <CAPS> { [ Super_L ] };
modifier_map Mod4 { <CAPS> };
};
// ralt as mod3
partial modifier_keys
xkb_symbols "ralt_mod3" {
include "group(switch)"
replace key <MENU> {
[ VoidSymbol, VoidSymbol ]
};
modifier_map Mod3 { <MENU> };
};
// group2 map for üöäß and some other things
partial alphanumeric_keys
xkb_symbols "group2_dvorak" {
key <AC01> { // A
symbols[Group2] = [ adiaeresis, Adiaeresis ]
};
key <AC02> { // O
symbols[Group2] = [ odiaeresis, Odiaeresis ]
};
key <AC04> { // U
symbols[Group2] = [ udiaeresis, Udiaeresis ]
};
key <AC10> { // S
symbols[Group2] = [ ssharp, ssharp ]
};
key <AB07> { // M
symbols[Group2] = [ mu, heart ]
};
key <TLDE> { // ~
symbols[Group2] = [ degree, infinity ]
};
// key <BKSP> {
// symbols[Group2] = [ BackSpace, BackSpace ]
// };
// key <SPCE> {
// symbols[Group2] = [ nobreakspace, nobreakspace ]
// };
// key <TAB> {
// symbols[Group2] = [ Tab, Tab ]
// };
// key <BKSP> {
// symbols[Group2] = [ BackSpace, BackSpace ]
// };
};

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 us:dvorak
remaps
done

View file

@ -59,7 +59,7 @@ onescreen() { # If only one output available or chosen.
postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed.
remaps -n # Re-remap keys if keyboard added (for laptop bases)
remaps # Re-remap keys if keyboard added (for laptop bases)
{
killall dunst
setsid -f dunst

View file

@ -1,35 +1,16 @@
#!/bin/sh
index() {
echo "$groups" | cut -d ' ' -f "$1"
}
XKBDIR="${XDG_CONFIG_HOME:-$HOME/.config}/X11/xkb"
XKBMAPFILE="$XKBDIR/keymap/$(hostname --fqdn)"
[ -r "$XKBMAPFILE" ] || XKBMAPFILE="$XKBDIR/keymap/default"
xkbcomp -I"$XKBDIR" "$XKBMAPFILE" "${DISPLAY%%.*}"
unset XKBDIR XKBMAPFILE
if [ "$1" = "-n" ]; then
newgroup="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
elif [ "$1" = "" ]; then
groups="us:dvorak de:nodeadkeys"
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
i=1
while [ ! "$found" ]; do
group=$(index $i)
if [ "$group" = "$current" ]; then
newgroup=$(index $((i + 1)))
[ -z "$newgroup" ] && newgroup=$(index 1)
found=true
elif [ -z "$group" ]; then
newgroup=$(index 1)
found=true
fi
i=$((i + 1))
done
else
newgroup="$1"
fi
setxkbmap -layout "$(echo "$newgroup" | cut -d ':' -f1)" -variant "$(echo "$newgroup" | cut -d ':' -f2)" -option caps:super -option terminate:ctrl_alt_bksp 1>/dev/null 2>&1 || echo "Unkown keyboard layout"
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'
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
sleep 0.03
[ "$1" != "-n" ] && pkill -RTMIN+15 dwmblocks

View file

@ -1,11 +0,0 @@
#!/bin/sh
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
setxkbmap -layout "$(echo "$current" | cut -d ':' -f1)" -variant "$(echo "$current" | cut -d ':' -f2)" -option caps:super -option terminate:ctrl_alt_bksp
xset r rate 300 50
killall xcape 2>/dev/null
xcape -e 'Super_L=Escape'
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock
sleep 0.03
pkill -RTMIN+15 dwmblocks

44
.local/bin/trash/remaps Executable file
View file

@ -0,0 +1,44 @@
#!/bin/sh
index() {
echo "$groups" | cut -d ' ' -f "$1"
}
if [ "$1" = "-n" ]; then
newgroup="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
elif [ "$1" = "" ]; then
groups="${XKB_LAYOUTS:-us}"
current="$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')"
i=1
while [ ! "$found" ]; do
group=$(index $i)
if [ "$group" = "$current" ]; then
newgroup=$(index $((i + 1)))
[ -z "$newgroup" ] && newgroup=$(index 1)
found=true
elif [ -z "$group" ]; then
newgroup=$(index 1)
found=true
fi
i=$((i + 1))
done
else
newgroup="$1"
fi
setxkbmap \
-layout "$(echo "$newgroup" | cut -d ':' -f1)" \
-variant "$(echo "$newgroup" | cut -d ':' -f2)" \
-option compose:ralt \
-option caps:super \
-option terminate:ctrl_alt_bksp 1>/dev/null 2>&1 ||
echo "Unkown keyboard layout" >&2
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

View file

@ -1,8 +0,0 @@
ä a
Ä A
ö o
Ö O
ü u
Ü U
ß s
€ $

File diff suppressed because it is too large Load diff