live-langset-data/langset.sh

52 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh
lang=en_US
for o in $(cat /proc/cmdline); do
case $o in
lang=*)
eval $o
;;
esac
done
# we need the _NOT so there is always a field 2
Country=$(echo "$lang"_NOT | cut -d_ -f2)
Language=$(echo "$lang" | cut -d_ -f1)
file="/usr/share/langset/$Language""_$Country"
if ! test -f "$file"; then
file="/usr/share/langset/$Language"
fi
layout=
model=
variant=
options=
sed -e 's,: *,:,' "$file" | while read line; do
key=`echo $line | cut -d: -f1`
value=`echo $line | cut -d: -f2-`
if [ "$key" = "XkbLayout" ]; then
layout="$value"
elif [ "$key" = "XkbModel" ]; then
model="$value"
elif [ "$key" = "XkbVariant" ]; then
variant="$value"
elif [ "$key" = "XkbOptions" ]; then
options="$value"
fi
sed -i -e "s#$key=\".*#$key=\"$value\"#" /etc/sysconfig/language
sed -i -e "s#$key=\".*#$key=\"$value\"#" /etc/sysconfig/keyboard
sed -i -e "s#$key=\".*#$key=\"$value\"#" /etc/sysconfig/console
if [ -n "$layout" ] && [ -n "$model" ] && [ -n "$variant" ] && [ -n "$options" ]; then
localectl set-x11-keymap "$layout" "$model" "$variant" "$options"
fi
done
echo "$Language""_$Country" > /var/lib/zypp/RequestedLocales
# Apply the settings
systemctl restart systemd-vconsole-setup