File sway-xkb-layout-generator-0.0.1+git20251204.58fbdcb.obscpio of Package sway-xkb-layout-generator
07070100000000000081A4000000000000000000000001693150D200000430000000000000000000000000000000000000003C00000000sway-xkb-layout-generator-0.0.1+git20251204.58fbdcb/LICENSEMIT License
Copyright (c) 2025 Filippo Bonazzi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
07070100000001000081A4000000000000000000000001693150D200000101000000000000000000000000000000000000003E00000000sway-xkb-layout-generator-0.0.1+git20251204.58fbdcb/README.md# sway-xkb-layout-generator
Generate a Sway keyboard configuration block with the xkb_* options
corresponding to the XKB* variables found in `/etc/vconsole.conf`.
## Requirements
- `udev` (for `/etc/vconsole.conf`)
- `systemd` (for `localectl`)
- `grep`
07070100000002000081ED000000000000000000000001693150D2000007B5000000000000000000000000000000000000004E00000000sway-xkb-layout-generator-0.0.1+git20251204.58fbdcb/sway-xkb-layout-generator#!/bin/sh
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# Author: Filippo Bonazzi <filippo.bonazzi@suse.com>
#
# Generate a Sway keyboard configuration block with the xkb_* options
# corresponding to the XKB* variables found in /etc/vconsole.conf
#
# The XKBLAYOUT variable is required. If not found in /etc/vconsole.conf,
# generate it by converting the configured vconsole keymap set by the system
# installer.
#
# See also: man 5 sway-input, man 7 xkeyboard-config, man 1 localectl
vconsole="/etc/vconsole.conf"
###############################################################################
# Extract the required XKB layout variable
xkb_layout="$(grep -Po '(?<=XKBLAYOUT=).*' $vconsole)"
# Generate the XKB layout if empty
if [ -z "$xkb_layout" ]; then
keymap="$(grep -Po '(?<=KEYMAP=).*' $vconsole)"
if [ -z "$keymap" ]; then
echo "fatal: no xkb layout or keymap found" >&2
exit 1
else
cp "$vconsole" "${vconsole}.bak"
# Set the XKB layout by converting the existing keymap
localectl set-keymap "$keymap"
# Try to extract the XKB layout again
xkb_layout="$(grep -Po '(?<=XKBLAYOUT=).*' $vconsole)"
if [ -z "$xkb_layout" ]; then
echo "fatal: could not generate xkb layout from keymap" >&2
exit 2
fi
fi
fi
# Extract the other optional XKB variables
xkb_model="$(grep -Po '(?<=XKBMODEL=).*' $vconsole)"
xkb_options="$(grep -Po '(?<=XKBOPTIONS=).*' $vconsole)"
xkb_variant="$(grep -Po '(?<=XKBVARIANT=).*' $vconsole)"
# Generate a Sway keyboard configuration block containing the required and
# optional variables
cat << EOF
# Set keyboard layout based on system setup
# Generated by $0 during installation
input "type:keyboard" {
xkb_layout $xkb_layout
EOF
if [ -n "$xkb_model" ]; then
echo " xkb_model $xkb_model"
fi
if [ -n "$xkb_options" ]; then
echo " xkb_options $xkb_options"
fi
if [ -n "$xkb_variant" ]; then
echo " xkb_variant $xkb_variant"
fi
echo "}"
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!8 blocks