commit 8bdaf163cbe73e438c1ca1dc47be5a6d30751e7f Author: atagen Date: Wed May 7 16:31:37 2025 +1000 init s s diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7b88181 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nix-systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746397377, + "narHash": "sha256-5oLdRa3vWSRbuqPIFFmQBGGUqaYZBxX+GGtN9f/n4lU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ed30f8aba41605e3ab46421e3dcb4510ec560ff8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-systems": "nix-systems", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..43776f3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nix-systems.url = "github:nix-systems/default-linux"; + }; + + outputs = + { + self, + nixpkgs, + nix-systems, + ... + }: + let + forAllSystems = ( + function: + nixpkgs.lib.genAttrs (import nix-systems) (system: function nixpkgs.legacyPackages.${system}) + ); + in + { + packages = forAllSystems (pkgs: { + default = pkgs.callPackage ./package.nix { }; + }); + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..e01fb40 --- /dev/null +++ b/package.nix @@ -0,0 +1,64 @@ +{ + stdenvNoCC, + fetchFromGitea, + lib, + selectedTheme ? "starship", + screenNumber ? 0, +}: +let + themeDetails = import ./themes.nix; + # validThemes = builtins.attrNames themeDetails; + # themeName = lib.checkListOfEnum "plymouth theme" validThemes selectedTheme; + themeName = selectedTheme; + theme = themeDetails.${themeName}; +in +stdenvNoCC.mkDerivation { + pname = "hudcore-plymouth"; + version = "${themeName}"; + + src = fetchFromGitea { + domain = "git.atagen.co"; + owner = "atagen"; + repo = "hudcore-plymouth"; + rev = theme.rev; + 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%/${toString screenNumber}/g' ${themeScript} + sed -i 's/%FRAME_COUNT%/${toString 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 ]; + }; +} diff --git a/template.plymouth b/template.plymouth new file mode 100644 index 0000000..1605e84 --- /dev/null +++ b/template.plymouth @@ -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 diff --git a/template.script b/template.script new file mode 100644 index 0000000..e100cd0 --- /dev/null +++ b/template.script @@ -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 = ""; + + 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); diff --git a/themes.nix b/themes.nix new file mode 100644 index 0000000..82dc416 --- /dev/null +++ b/themes.nix @@ -0,0 +1,7 @@ +{ + starship = { + frameCount = 480; + rev = "9347219f3dd5c1641b5a981b366290d946fdd777"; + hash = "sha256-3IhfX1XJE4lvNMjQrzscTww+xK6vjH1OOjb0JT3+AfY="; + }; +}