#!/bin/sh
# Write Hyprland's uwsm keyboard environment drop-in from the system console
# keyboard configuration (/etc/default/keyboard).
#
# hyprland.lua ships with an empty kb_layout, so libxkbcommon falls back to
# XKB_DEFAULT_*; this drop-in provides them for the uwsm-managed session.
# Run against the running system's paths, so it works both on the live media
# (fll-live-boot) and, chrooted, post-install (calamares) where it must run
# after the keyboard configuration has been written to the target.
set -eu

[ -r /etc/default/keyboard ] || exit 0
. /etc/default/keyboard

mkdir -p /etc/xdg/uwsm/env-hyprland.d
cat > /etc/xdg/uwsm/env-hyprland.d/10-keyboard <<EOF
export XKB_DEFAULT_LAYOUT="${XKBLAYOUT-}"
export XKB_DEFAULT_VARIANT="${XKBVARIANT-}"
export XKB_DEFAULT_MODEL="${XKBMODEL-}"
export XKB_DEFAULT_OPTIONS="${XKBOPTIONS-}"
EOF
