80 lines
3.0 KiB
Python
Executable File
80 lines
3.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Compile and verify Geminux Gemini PDA US XKB keymap using xkbcomp inside Docker."""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
XKB_OVERLAY = os.path.join(BASE_DIR, "overlay", "rootfs", "usr", "share", "X11", "xkb")
|
|
|
|
|
|
def main():
|
|
script = r"""
|
|
set -eu
|
|
cat > /etc/apk/repositories <<EOF
|
|
https://dl-cdn.alpinelinux.org/alpine/edge/main
|
|
https://dl-cdn.alpinelinux.org/alpine/edge/community
|
|
EOF
|
|
apk add --no-cache xkbcomp setxkbmap xkeyboard-config xvfb >/dev/null
|
|
cp -a /geminux-xkb/. /usr/share/X11/xkb/
|
|
Xvfb :99 -screen 0 640x480x24 >/dev/null 2>&1 &
|
|
XPID=$!
|
|
trap 'kill "$XPID" 2>/dev/null || true' EXIT
|
|
i=0
|
|
while [ "$i" -lt 20 ] && [ ! -S /tmp/.X11-unix/X99 ]; do
|
|
i=$((i + 1))
|
|
sleep 0.1
|
|
done
|
|
DISPLAY=:99 setxkbmap -rules evdev -model pc105 -layout 'planet_vndr/geminux' -variant us -option -option 'custom:types' -print > /tmp/gemini_rmlvo.xkb
|
|
cat /tmp/gemini_rmlvo.xkb
|
|
xkbcomp -w 3 -I/usr/share/X11/xkb /tmp/gemini_rmlvo.xkb /tmp/gemini.xkm
|
|
xkbcomp /tmp/gemini.xkm /tmp/gemini_dump.xkb
|
|
cat /tmp/gemini_dump.xkb
|
|
"""
|
|
res = subprocess.run(
|
|
["docker", "run", "--rm", "--network=host", "-v", f"{XKB_OVERLAY}:/geminux-xkb:ro",
|
|
"alpine:3.24", "sh", "-eu", "-c", script],
|
|
capture_output=True, text=True, check=False
|
|
)
|
|
if res.returncode != 0:
|
|
print(res.stdout)
|
|
print(res.stderr, file=sys.stderr)
|
|
return res.returncode
|
|
|
|
dump = res.stdout
|
|
checks = [
|
|
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
|
|
"asciitilde", "EuroSign", "Super_L", "ISO_Level3_Shift", "Mod4", "Mod5",
|
|
"GEMINUX_LALT", "GEMINUX_FN", "SetMods(modifiers=Mod4)",
|
|
'include "complete+custom"',
|
|
"XF86AudioLowerVolume", "XF86AudioRaiseVolume", "XF86AudioMute",
|
|
"XF86MonBrightnessDown", "XF86MonBrightnessUp", "Print",
|
|
"XF86AudioPlay", "XF86AudioPrev", "XF86AudioNext", "XF86AudioRecord",
|
|
"XF86Sleep", "XF86PowerDown", "XF86Tools",
|
|
"XF86TaskPane", "XF86TopMenu", "XF86UWB", "XF86Option",
|
|
]
|
|
for token in checks:
|
|
assert token in dump, f"Expected '{token}' in compiled XKB dump"
|
|
# Verify digit AE01 order: [ 1, exclam, F1, asciitilde ]
|
|
assert "[ 1, exclam, F1, asciitilde ]" in dump or \
|
|
"1, exclam, F1, asciitilde" in " ".join(dump.split()), \
|
|
"AE01 digit/F1/tilde mapping mismatch"
|
|
|
|
with open(os.path.join(BASE_DIR, "src", "dwm", "dwm.c"), "r", encoding="utf-8") as f:
|
|
dwm_src = f.read()
|
|
for needle in ("sym_lvl2", "sym_lvl3", "!(ev->state & (Mod4Mask | Mod1Mask))"):
|
|
assert needle in dwm_src, f"src/dwm/dwm.c missing {needle!r}"
|
|
|
|
with open(os.path.join(BASE_DIR, "src", "dwm", "config.def.h"), "r", encoding="utf-8") as f:
|
|
cfg_src = f.read()
|
|
for needle in ("geminux-media-key", "XF86XK_AudioRaiseVolume", "XF86XK_MonBrightnessUp", "XK_Print"):
|
|
assert needle in cfg_src, f"src/dwm/config.def.h missing {needle!r}"
|
|
|
|
print("[PASS] XKB compilation, Fn+Alt=Mod4, Fn+1..0, and DWM Level 3/4 media keys verified")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|