init
s
This commit is contained in:
commit
a86294645b
63
package.nix
Normal file
63
package.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
stdenvNoCC,
|
||||
fetchFromGitea,
|
||||
lib,
|
||||
selectedTheme ? "starship",
|
||||
screenNumber ? 0,
|
||||
}:
|
||||
let
|
||||
themeDetails = import ./themes.nix;
|
||||
validThemes = builtins.attrNames themeDetails;
|
||||
themeName = lib.checkListOfEnum "plymouth theme" validThemes selectedTheme;
|
||||
theme = themeDetails.${themeName};
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "hudcore-plymouth";
|
||||
version = themeName;
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "git.atagen.co";
|
||||
owner = "atagen";
|
||||
repo = "hudcore-plymouth";
|
||||
rev = themeName;
|
||||
hash = theme.hash;
|
||||
};
|
||||
|
||||
installPhase =
|
||||
let
|
||||
templateScript = ./template.script;
|
||||
templatePlymouth = ./template.plymouth;
|
||||
themeScript = "${themeName}.script";
|
||||
themePlymouth = "${themeName}.plymouth";
|
||||
in
|
||||
''
|
||||
cp ${templateScript} ${themeScript}
|
||||
sed -i 's/%SCREEN_NUMBER%/${screenNumber}/g' ${themeScript}
|
||||
sed -i 's/%FRAME_COUNT%/${theme.frameCount}/g' ${themeScript}
|
||||
|
||||
cp ${templatePlymouth} ${themePlymouth}
|
||||
sed -i 's/%NAME%/${themeName}/g' ${themePlymouth}
|
||||
|
||||
mkdir -p $out/share/plymouth/themes/${themeName}
|
||||
cp -r * $out/share/plymouth/themes/${themeName}
|
||||
'';
|
||||
|
||||
passthru.updateScript = { };
|
||||
|
||||
meta = {
|
||||
description = "Fantasy HUD Plymouth themes";
|
||||
longDescription = ''
|
||||
A set of mostly HUD-inspired plymouth boot screens.
|
||||
Default is `starship`.
|
||||
Override `selectedTheme` in order to pick a different one.
|
||||
Currently available:
|
||||
`nixdrop`
|
||||
`starship`
|
||||
`containment`
|
||||
'';
|
||||
homepage = "https://git.atagen.co/atagen/hudcore-plymouth";
|
||||
license = lib.licenses.gpl3;
|
||||
platforms = lib.platforms.linux;
|
||||
maintainers = [ lib.maintainers.atagen ];
|
||||
};
|
||||
}
|
8
template.plymouth
Normal file
8
template.plymouth
Normal file
@ -0,0 +1,8 @@
|
||||
[Plymouth Theme]
|
||||
Name=%NAME%
|
||||
Description=A theme from the atagen/hudcore-plymouth pack.
|
||||
ModuleName=script
|
||||
|
||||
[script]
|
||||
ImageDir=/usr/share/plymouth/themes/%NAME%
|
||||
ScriptFile=/usr/share/plymouth/themes/%NAME%/%NAME%.script
|
82
template.script
Normal file
82
template.script
Normal file
@ -0,0 +1,82 @@
|
||||
// based on work by Aditya Shakya (adi1090x@gmail.com)
|
||||
|
||||
screen.w = Window.GetWidth(%SCREEN_NUMBER%);
|
||||
screen.h = Window.GetHeight(%SCREEN_NUMBER%);
|
||||
screen.hw = screen.w / 2;
|
||||
screen.hh = screen.h / 2;
|
||||
cur_frame = 0;
|
||||
|
||||
for (i = 0; i < max_frames; i++) {
|
||||
images.img[i] = Image(i + ".png");
|
||||
}
|
||||
images.w = images[0].GetWidth()
|
||||
images.h = images[0].GetHeight()
|
||||
images.hw = images.w / 2
|
||||
images.hh = images.h / 2
|
||||
|
||||
draw = Sprite();
|
||||
draw.SetX(Window.GetX() + (screen.hw - images.hw));
|
||||
draw.SetY(Window.GetY() + (screen.hh - images.hh));
|
||||
|
||||
fun refresh () {
|
||||
image.SetImage(images.img[cur_frame]);
|
||||
cur_frame = (cur_frame + 1) % %FRAME_COUNT%;
|
||||
}
|
||||
Plymouth.SetRefreshFunction(refresh);
|
||||
|
||||
fun DisplayQuestionCallback(prompt, entry) {
|
||||
question = null;
|
||||
answer = null;
|
||||
|
||||
if (entry == "")
|
||||
entry = "<answer>";
|
||||
|
||||
question.image = Image.Text(prompt, 1, 1, 1);
|
||||
question.sprite = Sprite(question.image);
|
||||
question.sprite.SetX(screen.half.w - question.image.GetWidth() / 2);
|
||||
question.sprite.SetY(screen.h - 4 * question.image.GetHeight());
|
||||
|
||||
answer.image = Image.Text(entry, 1, 1, 1);
|
||||
answer.sprite = Sprite(answer.image);
|
||||
answer.sprite.SetX(screen.half.w - answer.image.GetWidth() / 2);
|
||||
answer.sprite.SetY(screen.h - 2 * answer.image.GetHeight());
|
||||
}
|
||||
Plymouth.SetDisplayQuestionFunction(DisplayQuestionCallback);
|
||||
|
||||
|
||||
fun DisplayPasswordCallback(nil, bulletCount) {
|
||||
state.status = "pause";
|
||||
totalWidth = bulletCount * bullet.image.GetWidth();
|
||||
startPos = screen.half.w - totalWidth / 2;
|
||||
|
||||
prompt.image = Image.Text("Enter Password", 1, 1, 1);
|
||||
prompt.sprite = Sprite(prompt.image);
|
||||
prompt.sprite.SetX(screen.half.w - prompt.image.GetWidth() / 2);
|
||||
prompt.sprite.SetY(screen.h - 4 * prompt.image.GetHeight());
|
||||
|
||||
// Clear all bullets (user might hit backspace)
|
||||
bullets = null;
|
||||
for (i = 0; i < bulletCount; i++) {
|
||||
bullets[i].sprite = Sprite(bullet.image);
|
||||
bullets[i].sprite.SetX(startPos + i * bullet.image.GetWidth());
|
||||
bullets[i].sprite.SetY(screen.h - 2 * bullet.image.GetHeight());
|
||||
}
|
||||
}
|
||||
Plymouth.SetDisplayPasswordFunction(DisplayPasswordCallback);
|
||||
|
||||
fun DisplayNormalCallback() {
|
||||
state.status = "play";
|
||||
bullets = null;
|
||||
prompt = null;
|
||||
message = null;
|
||||
question = null;
|
||||
answer = null;
|
||||
}
|
||||
Plymouth.SetDisplayNormalFunction(DisplayNormalCallback);
|
||||
|
||||
fun MessageCallback(text) {
|
||||
message.image = Image.Text(text, 1, 1, 1);
|
||||
message.sprite = Sprite(message.image);
|
||||
message.sprite.SetPosition(screen.half.w - message.image.GetWidth() / 2, message.image.GetHeight());
|
||||
}
|
||||
Plymouth.SetMessageFunction(MessageCallback);
|
6
themes.nix
Normal file
6
themes.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
starship = {
|
||||
frameCount = 450;
|
||||
hash = "0";
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user