From 174f4f2c99865244b055e8c0c8a7cb67b8c77966 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 4 Apr 2007 17:10:38 +0000 Subject: [PATCH] * Set the console font, the keymap, and Unicode/ASCII mode. svn path=/nixos/trunk/; revision=8542 --- system/options.nix | 22 ++++++++++++ upstart-jobs/default.nix | 17 ++++++--- upstart-jobs/kbd.nix | 78 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 upstart-jobs/kbd.nix diff --git a/system/options.nix b/system/options.nix index 7dae30f05bc..167a94d1b3a 100644 --- a/system/options.nix +++ b/system/options.nix @@ -868,4 +868,26 @@ } + { + name = ["i18n" "consoleFont"]; + default = "lat9w-16"; + example = "LatArCyrHeb-16"; + description = " + The font used for the virtual consoles. Leave empty to use + whatever the setfont program considers the + default font. + "; + } + + + { + name = ["i18n" "consoleKeyMap"]; + default = "us"; + example = "fr"; + description = " + The keyboard mapping table for the virtual consoles. + "; + } + + ] diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 4056e27e9ec..70193768378 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -9,6 +9,10 @@ let optional = option: service: if config.get option then [(makeJob service)] else []; + requiredTTYs = + (config.get ["services" "mingetty" "ttys"]) + ++ [10] /* !!! sync with syslog.conf */ ; + in import ../upstart-jobs/gather.nix { @@ -86,6 +90,15 @@ import ../upstart-jobs/gather.nix { inherit nssModulesPath; }) + # Console font and keyboard maps. + (import ../upstart-jobs/kbd.nix { + inherit (pkgs) glibc kbd gzip; + ttyNumbers = requiredTTYs; + defaultLocale = config.get ["i18n" "defaultLocale"]; + consoleFont = config.get ["i18n" "consoleFont"]; + consoleKeyMap = config.get ["i18n" "consoleKeyMap"]; + }) + # Handles the maintenance/stalled event (single-user shell). (import ../upstart-jobs/maintenance-shell.nix { inherit (pkgs) bash; @@ -193,10 +206,6 @@ import ../upstart-jobs/gather.nix { overridenTTYs = map (x: x.tty) specificThemes; - requiredTTYs = - (config.get ["services" "mingetty" "ttys"]) - ++ [10] /* !!! sync with syslog.conf */ ; - # Use the default theme for all the mingetty ttys and for the # syslog tty, except those for which a specific theme is # specified. diff --git a/upstart-jobs/kbd.nix b/upstart-jobs/kbd.nix new file mode 100644 index 00000000000..8be001b03d6 --- /dev/null +++ b/upstart-jobs/kbd.nix @@ -0,0 +1,78 @@ +{glibc, kbd, gzip, ttyNumbers, defaultLocale, consoleFont, consoleKeyMap}: + +let + + ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers; + +in + +{ + name = "kbd"; + + extraPath = [ + kbd + ]; + + job = " + description \"Keyboard / console initialisation\" + + start on udev + + script + + export LANG=${defaultLocale} + export PATH=${gzip}/bin:$PATH # Needed by setfont + + set +e # continue in case of errors + + + # Enable or disable UTF-8 mode. This is based on + # unicode_{start,stop}. + echo 'Enabling or disabling Unicode mode...' + + charMap=$(${glibc}/bin/locale charmap) + + if test \"$charMap\" = UTF-8; then + + for tty in ${toString ttys}; do + + # Tell the console output driver that the bytes arriving are + # UTF-8 encoded multibyte sequences. + echo -n -e '\\033%G' > $tty + + done + + # Set the keyboard driver in UTF-8 mode. + ${kbd}/bin/kbd_mode -u + + else + + for tty in ${toString ttys}; do + + # Tell the console output driver that the bytes arriving are + # UTF-8 encoded multibyte sequences. + echo -n -e '\\033%@' > $tty + + done + + # Set the keyboard driver in ASCII (or any 8-bit character + # set) mode. + ${kbd}/bin/kbd_mode -a + + fi + + + # Set the console font. + for tty in ${toString ttys}; do + ${kbd}/bin/setfont -C $tty ${consoleFont} + done + + + # Set the keymap. + ${kbd}/bin/loadkeys '${consoleKeyMap}' + + + end script + "; + +}