diff --git a/test/boot-environment.nix b/test/boot-environment.nix index af7b96785185..05099ee97bb2 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -113,6 +113,14 @@ rec { inherit (pkgs) openssh; }) + # Transparent TTY backgrounds. + (import ./upstart-jobs/tty-backgrounds.nix { + inherit (pkgs) stdenv splashutils; + backgrounds = (import ./splash-themes.nix { + inherit (pkgs) fetchurl; + }).ttyBackgrounds; + }) + # Handles the maintenance/stalled event (single-user shell). (import ./upstart-jobs/maintenance-shell.nix { inherit (pkgs) bash; diff --git a/test/splash-themes.nix b/test/splash-themes.nix new file mode 100644 index 000000000000..cbc725dda1c8 --- /dev/null +++ b/test/splash-themes.nix @@ -0,0 +1,45 @@ +{fetchurl}: + +rec { + + # Some themes. + + themeBabyTux = fetchurl { + url = http://www.bootsplash.de/files/themes/Theme-BabyTux.tar.bz2; + md5 = "a6d89d1c1cff3b6a08e2f526f2eab4e0"; + }; + + themeFrozenBubble = fetchurl { + url = http://www.bootsplash.de/files/themes/Theme-FrozenBubble.tar.bz2; + md5 = "da49f04988ab04b7e0de117b0d25061a"; + }; + + themePativo = fetchurl { + url = http://www.bootsplash.de/files/themes/Theme-Pativo.tar.bz2; + md5 = "9e13beaaadf88d43a5293e7ab757d569"; + }; + + + # The themes to use for each tty. For each tty except the first + # entry in the list, you can omit `theme' to get the same theme as + # the first one. If a tty does not appear, it doesn't get a + # theme (i.e., it will keep a black background). + + ttyBackgrounds = [ + { tty = 1; + theme = themeBabyTux; + } + { tty = 2; + } + { tty = 3; + theme = themeFrozenBubble; + } + { tty = 4; + theme = themePativo; + } + { tty = 6; + theme = themeFrozenBubble; + } + ]; + +} diff --git a/test/upstart-jobs/tty-backgrounds-combine.sh b/test/upstart-jobs/tty-backgrounds-combine.sh new file mode 100644 index 000000000000..50bab1fcd8cd --- /dev/null +++ b/test/upstart-jobs/tty-backgrounds-combine.sh @@ -0,0 +1,37 @@ +source $stdenv/setup + +ttys=($ttys) +themes=($themes) + +ensureDir $out + +default= + +for ((n = 0; n < ${#ttys[*]}; n++)); do + tty=${ttys[$n]} + theme=${themes[$n]} + + if test "$theme" = "default"; then + if test -z "$default"; then + echo "No default theme!" + exit 1 + fi + theme=$default + fi + + if test -z "$default"; then default=$theme; fi + + echo "TTY $tty -> $theme" + + themeName=$(cd $theme && ls) + + ln -sf $theme/$themeName $out/$themeName + + if test -e $out/$tty; then + echo "Multiple themes defined for the same TTY!" + exit 1 + fi + + ln -sf $themeName $out/$tty + +done diff --git a/test/upstart-jobs/tty-backgrounds.nix b/test/upstart-jobs/tty-backgrounds.nix new file mode 100644 index 000000000000..fd8eabea6a66 --- /dev/null +++ b/test/upstart-jobs/tty-backgrounds.nix @@ -0,0 +1,44 @@ +{stdenv, splashutils, backgrounds}: + +rec { + name = "tty-backgrounds"; + + unpackTheme = theme: stdenv.mkDerivation { + name = "theme"; + builder = ./unpack-theme.sh; + inherit theme; + }; + + themesUnpacked = stdenv.mkDerivation { + name = "splash-themes"; + builder = ./tty-backgrounds-combine.sh; + # !!! Should use XML here. + ttys = map (x: x.tty) backgrounds; + themes = map (x: if x ? theme then (unpackTheme x.theme) else "default") backgrounds; + }; + + job = " +start on hardware-scan + +script + + rm -f /etc/splash + ln -s ${themesUnpacked} /etc/splash + + # Critical: tell the kernel where to find splash_helper. It calls + # this program every time we switch between consoles. + echo ${splashutils}/bin/splash_helper > /proc/sys/kernel/fbsplash + + # Set the theme for each console, as determined by + # tty-backgrounds-combine.sh above. + for tty in ${toString (map (x: x.tty) backgrounds)}; do + theme=$(readlink ${themesUnpacked}/$tty) + ${splashutils}/bin/splash_util --tty $tty -c setcfg -t $theme || true + ${splashutils}/bin/splash_util --tty $tty -c setpic -t $theme || true + ${splashutils}/bin/splash_util --tty $tty -c on || true + done + +end script + "; + +} diff --git a/test/upstart-jobs/unpack-theme.sh b/test/upstart-jobs/unpack-theme.sh new file mode 100644 index 000000000000..c3a860692e50 --- /dev/null +++ b/test/upstart-jobs/unpack-theme.sh @@ -0,0 +1,16 @@ +source $stdenv/setup + +ensureDir $out + +tar xvfj $theme -C $out + +themeName=$(cd $out && ls) + +for i in $out/$themeName/config/*.cfg; do + echo "converting $i" + # Rewrite /etc paths. Also, the file names + # config/bootsplash-.cfg should be .cfg. + sed "s^/etc/bootsplash/themes^$out^g" < $i > $out/$themeName/$(basename $i | sed 's^.*-^^') +done + +rm $out/$themeName/config/*.cfg