feat(plymouth): add password prompt

This commit is contained in:
matt1432 2023-10-18 17:39:14 -04:00
parent b6e79db784
commit dd063c3606
3 changed files with 275 additions and 61 deletions

View file

@ -1,10 +1,13 @@
{ neovim-nightly-overlay, ... }:
{
imports = [
./dracula-theme.nix
];
nixpkgs.overlays = [
(import ./swayosd.nix)
(import ./blueberry.nix)
(import ./dracula-theme.nix)
(final: prev: {
spotifywm = final.callPackage ./pkgs/spotifywm.nix {};

View file

@ -1,82 +1,86 @@
final: prev: {
dracula-theme = prev.dracula-theme.overrideAttrs (oldAttrs: rec {
{ pkgs, ... }: let
plymouth = pkgs.fetchFromGitHub {
owner = "dracula";
repo = "plymouth";
rev = "37aa09b27ecee4a825b43d2c1d20b502e8f19c96";
hash = "sha256-7YwkBzkAND9lfH2ewuwna1zUkQStBBx4JHGw3/+svhA=";
};
plymouth = prev.fetchFromGitHub {
owner = "dracula";
repo = "plymouth";
rev = "37aa09b27ecee4a825b43d2c1d20b502e8f19c96";
hash = "sha256-7YwkBzkAND9lfH2ewuwna1zUkQStBBx4JHGw3/+svhA=";
};
dracula-script = ./patches/dracula-plymouth.patch;
git-colors = prev.fetchFromGitHub {
owner = "dracula";
repo = "git";
rev = "924d5fc32f7ca15d0dd3a8d2cf1747e81e063c73";
hash = "sha256-3tKjKn5IHIByj+xgi2AIL1vZANlb0vlYJsPjH6BHGxM=";
};
git-colors = pkgs.fetchFromGitHub {
owner = "dracula";
repo = "git";
rev = "924d5fc32f7ca15d0dd3a8d2cf1747e81e063c73";
hash = "sha256-3tKjKn5IHIByj+xgi2AIL1vZANlb0vlYJsPjH6BHGxM=";
};
wallpaper = prev.fetchurl {
url = "https://github.com/aynp/dracula-wallpapers/blob/main/Art/4k/Waves%201.png?raw=true";
hash = "sha256-f9FwSOSvqTeDj4bOjYUQ6TM+/carCD9o5dhg/MnP/lk=";
};
wallpaper = pkgs.fetchurl {
url = "https://github.com/aynp/dracula-wallpapers/blob/main/Art/4k/Waves%201.png?raw=true";
hash = "sha256-f9FwSOSvqTeDj4bOjYUQ6TM+/carCD9o5dhg/MnP/lk=";
};
in {
nixpkgs.overlays = [ (final: prev: {
dracula-theme = prev.dracula-theme.overrideAttrs (oldAttrs: rec {
src = prev.fetchFromGitHub {
owner = "dracula";
repo = "gtk";
rev = "84dd7a3021938ceec8a0ee292a8561f8a6d47ebe";
hash = "sha256-xHf+f0RGMtbprJX+3c0cmp5LKkf0V7BHKcoiAW60du8=";
};
src = prev.fetchFromGitHub {
owner = "dracula";
repo = "gtk";
rev = "84dd7a3021938ceec8a0ee292a8561f8a6d47ebe";
hash = "sha256-xHf+f0RGMtbprJX+3c0cmp5LKkf0V7BHKcoiAW60du8=";
};
preInstallPhase = ''
'';
installPhase = ''
runHook preInstall
installPhase = ''
runHook preInstall
# Git colors
cp -a ${git-colors}/config/gitconfig ./git-colors
chmod 777 ./git-colors
# Git colors
cp -a ${git-colors}/config/gitconfig ./git-colors
chmod 777 ./git-colors
line=$(grep -n 'Dracula Dark Theme' ./git-colors | cut -d: -f1)
sed -i "1,$((line-1))d" ./git-colors
line=$(grep -n 'Dracula Dark Theme' ./git-colors | cut -d: -f1)
sed -i "1,$((line-1))d" ./git-colors
mkdir -p $out
cp -a ./git-colors $out
mkdir -p $out
cp -a ./git-colors $out
# Plymouth
cp -a ${plymouth}/dracula ./dracula
chmod 777 ./dracula
# Plymouth
cp -a ${plymouth}/dracula ./dracula
chmod 777 ./dracula
rm ./dracula/dracula.script
cp -a ${dracula-script} ./dracula/dracula.script
sed -i "s@\/usr\/@$out\/@" ./dracula/dracula.plymouth
sed -i "s@\/usr\/@$out\/@" ./dracula/dracula.plymouth
mkdir -p $out/share/plymouth/themes
cp -a ./dracula $out/share/plymouth/themes/
mkdir -p $out/share/plymouth/themes
cp -a ./dracula $out/share/plymouth/themes/
# Wallpapers
cp -a ${wallpaper} ./waves.png
# Wallpapers
cp -a ${wallpaper} ./waves.png
mkdir -p $out/wallpapers
cp -a ./waves.png $out/wallpapers/
mkdir -p $out/wallpapers
cp -a ./waves.png $out/wallpapers/
# -------------------------------------------
mkdir -p $out/share/themes/Dracula
cp -a {assets,cinnamon,gnome-shell,gtk-2.0,gtk-3.0,gtk-3.20,gtk-4.0,index.theme,metacity-1,unity,xfwm4} $out/share/themes/Dracula
# -------------------------------------------
mkdir -p $out/share/themes/Dracula
cp -a {assets,cinnamon,gnome-shell,gtk-2.0,gtk-3.0,gtk-3.20,gtk-4.0,index.theme,metacity-1,unity,xfwm4} $out/share/themes/Dracula
cp -a kde/{color-schemes,plasma} $out/share/
cp -a kde/kvantum $out/share/Kvantum
cp -a kde/{color-schemes,plasma} $out/share/
cp -a kde/kvantum $out/share/Kvantum
mkdir -p $out/share/aurorae/themes
cp -a kde/aurorae/* $out/share/aurorae/themes/
mkdir -p $out/share/aurorae/themes
cp -a kde/aurorae/* $out/share/aurorae/themes/
mkdir -p $out/share/sddm/themes
cp -a kde/sddm/* $out/share/sddm/themes/
mkdir -p $out/share/sddm/themes
cp -a kde/sddm/* $out/share/sddm/themes/
mkdir -p $out/share/icons/Dracula-cursors
mv kde/cursors/Dracula-cursors/index.theme $out/share/icons/Dracula-cursors/cursor.theme
mv kde/cursors/Dracula-cursors/cursors $out/share/icons/Dracula-cursors/cursors
mkdir -p $out/share/icons/Dracula-cursors
mv kde/cursors/Dracula-cursors/index.theme $out/share/icons/Dracula-cursors/cursor.theme
mv kde/cursors/Dracula-cursors/cursors $out/share/icons/Dracula-cursors/cursors
runHook postInstall
'';
});
runHook postInstall
'';
});
}) ];
}

View file

@ -0,0 +1,207 @@
Window.SetBackgroundTopColor (0, 0, 0);
Window.SetBackgroundBottomColor (0, 0, 0);
bg_image = Image ("bg.png");
bg_image = bg_image.Scale (Window.GetWidth (),Window.GetHeight ());
bg = Sprite (bg_image);
bg.SetZ (-10);
yPos = (2/5);
if (Plymouth.GetMode () == "shutdown")
{
yPos = 0.5;
}
s = 0.75;
logo_image = Image ("logo.png");
logo_image = logo_image.Scale (120 * s , 120 * s);
logo = Sprite (logo_image);
logo.SetX (Window.GetWidth () / 2 - logo_image.GetWidth() / 2);
logo.SetY ((Window.GetHeight() * yPos) - logo_image.GetHeight() / 2);
istatic = Image ("static.png");
istatic = istatic.Scale (istatic.GetWidth() * s * 0.3 ,istatic.GetHeight() * s * 0.3 );
static = Sprite (istatic);
static.SetX (Window.GetWidth () / 2 - istatic.GetWidth() / 2);
static.SetY ((Window.GetHeight() * yPos) - istatic.GetHeight() / 2);
ic1 = Image ("1.png");
ic1 = ic1.Scale (ic1.GetWidth() * s ,ic1.GetHeight() * s );
c1 = Sprite (ic1);
c1.SetX (Window.GetWidth () / 2 - ic1.GetWidth() / 2);
c1.SetY ((Window.GetHeight() * yPos) - ic1.GetHeight() / 2);
ic2 = Image ("2.png");
ic2 = ic2.Scale (ic2.GetWidth() * s ,ic2.GetHeight() * s );
c2 = Sprite (ic2);
c2.SetX (Window.GetWidth () / 2 - ic2.GetWidth() / 2);
c2.SetY ((Window.GetHeight() * yPos) - ic2.GetHeight() / 2);
ic3 = Image ("3.png");
ic3 = ic3.Scale (ic3.GetWidth() * s ,ic3.GetHeight() * s );
c3 = Sprite (ic3);
c3.SetX (Window.GetWidth () / 2 - ic3.GetWidth() / 2);
c3.SetY ((Window.GetHeight() * yPos) - ic3.GetHeight() / 2);
ic4 = Image ("4.png");
ic4 = ic4.Scale (ic4.GetWidth() * s ,ic4.GetHeight() * s );
c4 = Sprite (ic4);
c4.SetX (Window.GetWidth () / 2 - ic4.GetWidth() / 2);
c4.SetY ((Window.GetHeight() * yPos) - ic4.GetHeight() / 2);
ic5 = Image ("5.png");
ic5 = ic5.Scale (ic5.GetWidth() * s ,ic5.GetHeight() * s );
c5 = Sprite (ic5);
c5.SetX (Window.GetWidth () / 2 - ic5.GetWidth() / 2);
c5.SetY ((Window.GetHeight() * yPos) - ic5.GetHeight() / 2);
ic6 = Image ("6.png");
ic6 = ic6.Scale (ic6.GetWidth() * s ,ic6.GetHeight() * s );
c6 = Sprite (ic6);
c6.SetX (Window.GetWidth () / 2 - ic6.GetWidth() / 2);
c6.SetY ((Window.GetHeight() * yPos) - ic6.GetHeight() / 2);
ic7 = Image ("7.png");
ic7 = ic7.Scale (ic7.GetWidth() * s ,ic7.GetHeight() * s );
c7 = Sprite (ic7);
c7.SetX (Window.GetWidth () / 2 - ic7.GetWidth() / 2);
c7.SetY ((Window.GetHeight() * yPos) - ic7.GetHeight() / 2);
ic8 = Image ("8.png");
ic8 = ic8.Scale (ic8.GetWidth() * s ,ic8.GetHeight() * s );
c8 = Sprite (ic8);
c8.SetX (Window.GetWidth () / 2 - ic8.GetWidth() / 2);
c8.SetY ((Window.GetHeight() * yPos) - ic8.GetHeight() / 2);
ic9 = Image ("9.png");
ic9 = ic9.Scale (ic9.GetWidth() * s ,ic9.GetHeight() * s );
c9 = Sprite (ic9);
c9.SetX (Window.GetWidth () / 2 - ic9.GetWidth() / 2);
c9.SetY ((Window.GetHeight() * yPos) - ic9.GetHeight() / 2);
ic10 = Image ("10.png");
ic10 = ic10.Scale (ic10.GetWidth() * s ,ic10.GetHeight() * s );
c10 = Sprite (ic10);
c10.SetX (Window.GetWidth () / 2 - ic10.GetWidth() / 2);
c10.SetY ((Window.GetHeight() * yPos) - ic10.GetHeight() / 2);
t=0;
fun update ()
{
t++;
c1.SetImage(ic1.Rotate(t * 0.009));
c2.SetImage(ic2.Rotate(t * 0.007));
c3.SetImage(ic3.Rotate(t * 0.006));
c4.SetImage(ic4.Rotate(t * 0.0053));
c5.SetImage(ic5.Rotate(t * 0.0048));
c6.SetImage(ic6.Rotate(t * 0.004));
c7.SetImage(ic7.Rotate(t * 0.0035));
c8.SetImage(ic8.Rotate(t * 0.003));
c9.SetImage(ic9.Rotate(t * 0.0025));
c10.SetImage(ic10.Rotate(t * 0.002));
}
Plymouth.SetRefreshFunction (update);
#----------------------------------------- Progress Bar --------------------------------
if (Plymouth.GetMode () == "boot")
{
ipb = Image ("pb.png");
pb = ipb.Scale (1 , 3);
pb = Sprite (ipb);
pb.SetX (Window.GetWidth () / 2 - 50);
pb.SetY ((Window.GetHeight() * (2/3)) - ipb.GetHeight() / 2);
fun progress_callback (duration, progress)
{
pb.SetImage(ipb.Scale ( progress * 100, 3));
}
Plymouth.SetBootProgressFunction(progress_callback);
}
# From https://github.com/adi1090x/plymouth-themes
// Screen size
screen.w = Window.GetWidth(0);
screen.h = Window.GetHeight(0);
screen.half.w = Window.GetWidth(0) / 2;
screen.half.h = Window.GetHeight(0) / 2;
// Question prompt
question = null;
answer = null;
// Message
message = null;
// Password prompt
bullets = null;
prompt = null;
bullet.image = Image.Text("*", 1, 1, 1);
// Flow
state.status = "play";
state.time = 0.0;
//------------------------------------- Password prompt -------------------------------
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);
//------------------------------------- Password prompt -------------------------------
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);
//--------------------------- Normal display (unset all text) ----------------------
fun DisplayNormalCallback() {
state.status = "play";
bullets = null;
prompt = null;
message = null;
question = null;
answer = null;
}
Plymouth.SetDisplayNormalFunction(DisplayNormalCallback);
//----------------------------------------- Message --------------------------------
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);