1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-18 13:31:36 +03:00
mobile-nixos/boot/init/tasks/splash.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

2019-12-23 06:32:34 +03:00
# Adds a minimal set of files required for logging-in.
class Tasks::Splash < SingletonTask
def initialize()
add_dependency(:Target, :Graphics)
add_dependency(:Task, Tasks::ProgressSocket.instance)
2019-12-23 06:32:34 +03:00
end
def run()
args = []
if LOG_LEVEL == Logger::DEBUG
args << "--verbose"
end
begin
@pid = System.spawn(LOADER, "/applets/boot-splash.mrb", *args)
# Don't fail the boot if the splash fails
rescue System::CommandError
end
2019-12-23 06:32:34 +03:00
end
def ux_priority()
-100
end
# Implementation details-y; ask for the splash applet to be exited.
def quit(reason)
# Ensures the progress is shown
Progress.update({progress: 100, label: reason})
# Command it to quit
Progress.update({command: {name: "quit"}})
# Ensures that if for any reason the splash didn't start in time for the
# socket to listen to this message, that we'll be quitting it.
loop do
# Repeatedly send the current state (which has the quit command).
Progress.send_state()
# If it has quit, break out!
break if Process.wait(@pid, Process::WNOHANG)
# Leave some breathing room to the CPU!
sleep(0.1)
end
end
2019-12-23 06:32:34 +03:00
end