Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/files/GRMLBASE/etc/locale.gen
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@
# change this file without affecting the use of debconf, however, since it
# does read in your changes.

# Locales for languages supported by grml-lang
de_AT.UTF-8 UTF-8
de_CH.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
en_GB.UTF-8 UTF-8
en_US.UTF-8 UTF-8
es_ES.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
hu_HU.UTF-8 UTF-8
it_IT.UTF-8 UTF-8
ja_JP.UTF-8 UTF-8
175 changes: 60 additions & 115 deletions config/files/GRMLBASE/usr/bin/grml-lang
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,45 @@ PN="$(basename "$0")"

usage(){
echo "Usage: ${PN} <language>"
echo "supported values: at, ch, de, dvorak, es, fr, it, jp, uk, us"
echo "supported values: at, ch, de, dvorak, es, fr, hu, it, jp, uk, us"
}

setvalue(){
[ -n "$2" ] || return 1
sudo sed -i "s#^${1}=.*#${1}=\"${2}\"#" "${CONFFILE}"
sudo sed -i --follow-symlinks "s#^${1}=.*#${1}=\"${2}\"#" "${CONFFILE}"
}

# Update keyboard configuration and apply changes
configure_keyboard(){
local layout="$1"
local variant="${2:-}"

# Update /etc/default/keyboard
if [ -r "$CONFFILE" ] ; then
setvalue XKBLAYOUT "$layout"
setvalue XKBVARIANT "$variant"
else
# Create the file if it doesn't exist
sudo tee "$CONFFILE" > /dev/null <<EOF
# Keyboard configuration for grml
XKBMODEL="pc105"
XKBLAYOUT="$layout"
EOF
if [ -n "$variant" ] ; then
echo "XKBVARIANT=\"$variant\"" | sudo tee -a "$CONFFILE" > /dev/null
fi
fi

# Apply keyboard changes immediately:
# Let setupcon update the files /etc/console-setup/cached*. It will also try
# to activate the new configuration.
sudo setupcon --force --save
# However, due to an apparenty loadkeys or kernel limitation, when the current
# screen is managed by X11, loadkeys *without* -u fails or does nothing. Force
# loading the keymap for the linux virtual consoles.
sudo loadkeys -u /etc/console-setup/cached_UTF-8_del.kmap.gz
# Trigger udev rules for input devices. If X11 is installed, this will make
# udev pick up /etc/default/keyboard, and X11 will pick up the keymap from udev.
sudo udevadm trigger --subsystem-match=input --action=change
}

if [ $# -lt "1" ] ; then
Expand All @@ -27,121 +60,33 @@ fi
LANGUAGE="$1"

# shellcheck disable=SC1091
. /etc/grml/language-functions
. /usr/share/grml-autoconfig/language-functions

if [ -n "$XKEYBOARD" ] ; then
setvalue XKBLAYOUT "$XKEYBOARD"
# Check if we found a valid keyboard configuration
if [ -z "$XKEYBOARD" ] ; then
echo "E: No valid language given."
echo
usage
echo
echo "Notice: grml-lang now configures keyboard layout via /etc/default/keyboard."
echo "For locale settings, use grml-setlang."
exit 1
fi

if [ -z "$DISPLAY" ] ;then
if [ "$1" = "de" ] ; then
echo "Loading keymap for Germany..."
sudo loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz
echo -e "\nDone."
elif [ "$1" = "at" ] ; then
echo "Loading keymap for Austria..."
sudo loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz
echo -e "\nDone."
elif [ "$1" = "ch" ] ; then
echo "Loading keymap for Switzerland..."
sudo loadkeys i386/qwertz/sg-latin1.kmap.gz
echo -e "\nDone."
elif [ "$1" = "it" ] ; then
echo "Loading keymap for Italy..."
sudo loadkeys i386/qwerty/it.kmap.gz
echo -e "\nDone."
elif [ "$1" = "us" ] ; then
echo 'Loading keymap us...'
sudo loadkeys i386/qwerty/us-latin1.kmap.gz
echo -e "\nDone."
elif [ "$1" = "dvorak" ] ; then
echo 'Loading keymap dvorak...'
sudo loadkeys dvorak
echo -e "\nDone."
elif [ "$1" = "jp" ] ; then
echo 'Loading keymap jp...'
sudo loadkeys i386/qwerty/jp106.kmap.gz
echo -e "\nDone."
elif [ "$1" = "es" ] ; then
echo 'Loading keymap es...'
sudo loadkeys i386/qwerty/es.kmap.gz
echo -e "\nDone."
elif [ "$1" = "fr" ] ; then
echo 'Loading keymap fr...'
sudo loadkeys i386/azerty/fr.kmap.gz
echo -e "\nDone."
elif [ "$1" = "uk" ] ; then
echo 'Loading keymap uk...'
sudo loadkeys i386/qwerty/uk.kmap.gz
echo -e "\nDone."
else echo "No valid parameter given.

Notice: Use loadkeys on console and setxkbmap when running X for
modifying keyboard layout. Adjust \$LANG and \$LC_ALL for setting locales." ; exit 1
fi
# switch to unicode mode on console
case $LANG in *UTF-8) kbd_mode -u ; ;; esac
else
if [ $# = 0 ] ; then
usage
else
if [ "$1" = "de" ] ; then
echo "Loading keymap for Germany..."
if [ -r "${HOME}"/.Xmodmap.german ] ; then
xmodmap "${HOME}"/.Xmodmap.german || setxkbmap de
else
setxkbmap de
fi
echo -e "\nDone."
elif [ "$1" = "at" ] ; then
echo "Loading keymap for Austria..."
setxkbmap de
echo -e "\nDone."
elif [ "$1" = "ch" ] ; then
echo "Loading keymap for Switzerland..."
setxkbmap ch
echo -e "\nDone."
elif [ "$1" = "it" ] ; then
echo "Loading keymap for Italy..."
setxkbmap it
echo -e "\nDone."
elif [ "$1" = "jp" ] ; then
echo "Loading keymap for Japan..."
setxkbmap -model jp106 -layout jp
echo -e "\nDone."
elif [ "$1" = "dvorak" ] ; then
echo "Loading keymap dvorak..."
setxkbmap dvorak
echo -e "\nDone."
elif [ "$1" = "us" ] ; then
echo 'Loading keymap us...'
if [ -r "${HOME}"/.Xmodmap ] ; then
xmodmap "${HOME}"/.Xmodmap || setxkbmap us
else
setxkbmap us
fi
echo -e "\nDone."
elif [ "$1" = "es" ] ; then
echo "Loading keymap es..."
setxkbmap es
echo -e "\nDone."
elif [ "$1" = "fr" ] ; then
echo "Loading keymap fr..."
setxkbmap fr
echo -e "\nDone."
elif [ "$1" = "uk" ] ; then
echo "Loading keymap gb for uk..."
setxkbmap gb
echo -e "\nDone."
else
echo "No valid parameter given."
echo
usage
echo
echo "Notice: Use loadkeys on console and setxkbmap when running X for
modifying keyboard layout. Adjust \$LANG and \$LC_ALL for setting locales." ; exit 1
fi
fi
if [ -n "$XKEYBOARD" ] ; then
# Determine variant based on language
case "$LANGUAGE" in
de|at)
configure_keyboard "$XKEYBOARD" "nodeadkeys"
;;
*)
configure_keyboard "$XKEYBOARD"
;;
esac
fi

echo "Keyboard layout configured: $XKEYBOARD"
[ -n "$2" ] && echo "Variant: $2"
echo "Done."

## END OF FILE #################################################################
137 changes: 68 additions & 69 deletions config/files/GRMLBASE/usr/sbin/grml-setlang
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

PN="$(basename "$0")"
DIALOG=dialog
LANGFUNC=/etc/grml/language-functions
LANGFUNC=/usr/share/grml-autoconfig/language-functions

# notice: Debian's locales.postinst has been modified to write
# locale variables into /etc/default/locale instead of
Expand Down Expand Up @@ -42,16 +42,39 @@ setvalue(){
[ -n "$2" ] || return 1
# already present in conffile?
if grep -q "^${1}" "$CONFFILE" ; then
sed -i "s#^${1}.*#${1}${2}#" $CONFFILE
sed -i --follow-symlinks "s#^${1}.*#${1}${2}#" $CONFFILE
# is the new Debian style /etc/default/locale present?
elif grep -q "^# ${1}$" "$CONFFILE" ; then
# shellcheck disable=SC1117
sed -i "s#^\# ${1}#${1}${2}#" $CONFFILE
sed -i --follow-symlinks "s#^\# ${1}#${1}${2}#" $CONFFILE
else
echo "$1${2}" >> $CONFFILE
fi
}

# Generate locale if necessary
generate_locale(){
local locale="$1"

# If locales-all is installed, we don't need to generate anything
if dpkg -s locales-all >/dev/null 2>&1 ; then
return 0
fi

# Check if locale is already in /etc/locale.gen
if ! grep -q "^$locale " /etc/locale.gen 2>/dev/null ; then
# Add the locale to /etc/locale.gen
echo "$locale UTF-8" >> /etc/locale.gen

# Remove autogenerated markers if present
sed -i --follow-symlinks '/^# This file was created by grml-live/d' /etc/locale.gen
sed -i --follow-symlinks '/^# XXX GENERATED XXX/d' /etc/locale.gen

# Generate the locale
locale-gen --keep-existing >/dev/null 2>&1
fi
}

# grml-small does not provide any further locales
if grep -q small /etc/grml_version 2>/dev/null ; then
if [ -z "$NONINTERACTIVE" ] ; then
Expand Down Expand Up @@ -88,73 +111,41 @@ which locales should be generated by locale-gen)
please run 'dpkg-reconfigure locales' manually.

Configuration will be written to $CONFFILE" 0 0 0 \
at 'austria (unicode version)' off \
at-iso 'austrian (iso version)' off \
au 'austrial (unicode version)' off \
au-iso 'australian (iso version)' off \
be 'belgian (unicode version)' off \
be-iso 'belgian (iso version)' off \
bg 'bulgarian (unicode version)' off \
bg-iso 'bulgarian (iso version)' off \
br 'brazilian (unicode version)' off \
br-iso 'brazilian (iso version)' off \
ch 'swiss (unicode version)' off \
ch-iso 'swiss (iso version)' off \
at 'austrian' off \
au 'austrialian' off \
be 'belgian' off \
bg 'bulgarian' off \
br 'brazilian' off \
ch 'swiss-german' off \
cf 'french canadian' off \
cn 'chinese (unicode version)' off \
cn-iso 'chinese (iso version)' off \
cs 'czech (unicode version)' off \
cs-iso 'czech (iso version)' off \
cz 'czech (unicode version)' off \
cz-iso 'czech (iso version)' off \
de 'german (unicode version)' off \
de-iso 'german (iso version)' off \
dk 'dansk (unicode version)' off \
dk-iso 'dansk (iso version)' off \
da 'dansk (unicode version)' off \
da-iso 'dansk (iso version)' off \
el 'greek (unicode version)' off \
el-iso 'greek (iso version)' off \
en 'english [us] (unicode version, grml default)' on \
en-iso 'english [us] (iso version)' off \
es 'spanish (unicode version)' off \
es-iso 'spanish (iso version)' off \
fi 'finnish (unicode version)' off \
fi-iso 'finnish (iso version)' off \
fr 'frensh (unicode version)' off \
fr-iso 'frensh (iso version)' off \
ga 'irish gaeilge (unicode version)' off \
ga-iso 'irish gaeilge (iso version)' off \
he 'hebrew (unicode version)' off \
he-iso 'hebrew (iso version)' off \
il 'hebrew (unicode version)' off \
il-iso 'hebrew (iso version)' off \
ie 'irish (unicode version)' off \
ie-iso 'irish (iso version)' off \
it 'italian (unicode version)' off \
it-iso 'italian (iso version)' off \
ja 'japanese (unicode version)' off \
ja-iso 'japanese (iso version)' off \
nl 'dutch (unicode version)' off \
nl-iso 'dutch (iso version)' off \
pl 'polish (unicode version)' off \
pl-iso 'polisch (iso version)' off \
pt 'portuguese (unicode version)' off \
pt-iso 'portuguese (iso version)' off \
ru 'russian (unicode version)' off \
ru-iso 'russian (iso version)' off \
sk 'slovak (unicode version)' off \
sk-iso 'slovak (iso version)' off \
sl 'slovenian (unicode version)' off \
sl-iso 'slovenian (iso version)' off \
tr 'turkish (unicode version)' off \
tr-iso 'turkish (iso version)' off \
tw 'chinese (traditional) (unicode version)' off \
tw-iso 'chinese (traditional) (iso version)' off \
uk 'british (unicode version)' off \
uk-iso 'british (iso version)' off \
us 'american (unicode version)' off \
us-iso 'american (iso version)' off \
cn 'chinese' off \
cs 'czech' off \
cz 'czech' off \
de 'german' off \
dk 'dansk' off \
da 'dansk' off \
el 'greek' off \
en 'english [us] (grml default)' on \
es 'spanish' off \
fi 'finnish' off \
fr 'french' off \
ga 'irish gaeilge' off \
he 'hebrew' off \
hu 'hungarian' off \
il 'hebrew' off \
ie 'irish' off \
it 'italian' off \
ja 'japanese' off \
nl 'dutch' off \
pl 'polish' off \
pt 'portuguese' off \
ru 'russian' off \
sk 'slovak' off \
sl 'slovenian' off \
tr 'turkish' off \
tw 'chinese (traditional)' off \
uk 'british' off \
us 'american' off \
)
}

Expand Down Expand Up @@ -204,6 +195,14 @@ LANG=$LANG
EOF
fi

# Remove grml-live header when the file gets changed
if [ -r "$CONFFILE" ] && grep -q "# grml-live" "$CONFFILE" ; then
sed -i --follow-symlinks '/^# grml-live/d' "$CONFFILE"
fi

# Generate locale if necessary
generate_locale "$LANG"

setvalue 'LANG=' "$LANG"

retval=$?
Expand Down
Loading
Loading