mirror of
https://github.com/danth/stylix
synced 2025-02-16 21:38:40 +00:00
Add Plymouth module
This commit is contained in:
parent
7cefd745bf
commit
c8addbbf5a
3 changed files with 84 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
./modules/gtk.nix
|
||||
./modules/kitty.nix
|
||||
./modules/lightdm.nix
|
||||
./modules/plymouth
|
||||
./modules/qutebrowser.nix
|
||||
./modules/vim.nix
|
||||
];
|
||||
|
|
35
modules/plymouth/default.nix
Normal file
35
modules/plymouth/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
with config.lib.stylix.colors;
|
||||
|
||||
let theme = pkgs.runCommandLocal "plymouth-theme" {}
|
||||
''
|
||||
themeDir="$out/share/plymouth/themes/stylix"
|
||||
mkdir -p $themeDir
|
||||
|
||||
cp ${./theme.script} $themeDir/stylix.script
|
||||
|
||||
# Convert in case the input image is not PNG
|
||||
${pkgs.imagemagick}/bin/convert ${config.stylix.image} $themeDir/background.png
|
||||
|
||||
# A single pixel of base0B, will be stretched to make the progress bar
|
||||
# (Plymouth scripts can only display images)
|
||||
${pkgs.imagemagick}/bin/convert xc:#${base0B-hex} $themeDir/progress.png
|
||||
|
||||
echo "
|
||||
[Plymouth Theme]
|
||||
Name=Stylix
|
||||
ModuleName=script
|
||||
|
||||
[script]
|
||||
ImageDir=$themeDir
|
||||
ScriptFile=$themeDir/stylix.script
|
||||
" > $themeDir/stylix.plymouth
|
||||
'';
|
||||
|
||||
in {
|
||||
boot.plymouth = {
|
||||
theme = "stylix";
|
||||
themePackages = [ theme ];
|
||||
};
|
||||
}
|
48
modules/plymouth/theme.script
Normal file
48
modules/plymouth/theme.script
Normal file
|
@ -0,0 +1,48 @@
|
|||
### BACKGROUND ###
|
||||
|
||||
background.original_image = Image("background.png");
|
||||
background.ratio = Math.Max(
|
||||
Window.GetWidth() / background.original_image.GetWidth(),
|
||||
Window.GetHeight() / background.original_image.GetHeight()
|
||||
);
|
||||
background.image = background.original_image.Scale(
|
||||
Math.Int(background.original_image.GetWidth() * background.ratio),
|
||||
Math.Int(background.original_image.GetHeight() * background.ratio)
|
||||
);
|
||||
background.sprite = Sprite(background.image);
|
||||
background.sprite.SetPosition(
|
||||
Math.Int((Window.GetWidth() - background.image.GetWidth()) / 2),
|
||||
Math.Int((Window.GetHeight() - background.image.GetHeight()) / 2),
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
### PROGRESS ###
|
||||
|
||||
progress_bar.width = 0;
|
||||
progress_bar.height = 4;
|
||||
|
||||
progress_bar.original_image = Image("progress.png");
|
||||
progress_bar.sprite = Sprite();
|
||||
progress_bar.sprite.SetY(Window.GetHeight() - progress_bar.height);
|
||||
progress_bar.sprite.SetZ(1);
|
||||
|
||||
fun progress_callback (duration, progress) {
|
||||
progress_bar.width = Math.Int(Window.GetWidth() * progress);
|
||||
|
||||
if (progress_bar.image.GetWidth() != progress_bar.width) {
|
||||
progress_bar.image = progress_bar.original_image.Scale(progress_bar.width, progress_bar.height);
|
||||
progress_bar.sprite.SetImage(progress_bar.image);
|
||||
}
|
||||
}
|
||||
|
||||
Plymouth.SetBootProgressFunction(progress_callback);
|
||||
|
||||
|
||||
### QUIT ###
|
||||
|
||||
fun quit_callback () {
|
||||
progress_bar.sprite.SetOpacity(0);
|
||||
}
|
||||
|
||||
Plymouth.SetQuitFunction(quit_callback);
|
Loading…
Add table
Reference in a new issue