nixpkgs-suyu/upstart-jobs/tty-backgrounds.nix
Eelco Dolstra fb2d9f8347 * Race condition: splash_util fails if the virtual console doesn't
exist yet (e.g., because mingetty hasn't started yet), so make sure
  it exists.

svn path=/nixos/trunk/; revision=7584
2007-01-09 13:56:54 +00:00

56 lines
1.5 KiB
Nix

{stdenv, splashutils, backgrounds}:
rec {
name = "tty-backgrounds";
unpackTheme = theme: import ../helpers/unpack-theme.nix {
inherit stdenv 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
start 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
# For each console...
for tty in ${toString (map (x: x.tty) backgrounds)}; do
# Make sure that the console exists.
echo -n '' > /dev/tty$tty
# Set the theme as determined by tty-backgrounds-combine.sh
# above.
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
respawn sleep 10000 # !!! Hack
stop script
# Disable the theme on each console.
for tty in ${toString (map (x: x.tty) backgrounds)}; do
${splashutils}/bin/splash_util --tty $tty -c off || true
done
end script
";
}