#!/bin/bash

## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## "$1" = path to installed system root directory

set -o errexit
set -o nounset
set -o errtrace
set -o pipefail

setxkbmap_output="$(setxkbmap -query)"
kb_layout="$(awk '/layout/{ print $2 }' <<< "${setxkbmap_output}")"
kb_variant="$(awk '/variant/{ print $2 }' <<< "${setxkbmap_output}")"
kb_options="$(awk '/options/{ print $2 }' <<< "${setxkbmap_output}")"
printf '%s\n' "${kb_layout}" "${kb_variant}" "${kb_options}" > /dev/shm/fixkb-layout

mount --bind /dev/shm "$1"/dev/shm
