add(hyprlock): added typewriter animtaion

This commit is contained in:
kenji
2026-01-01 16:56:02 -06:00
parent f2f44f2fdd
commit a85014188f
5 changed files with 123 additions and 11 deletions
+8
View File
@@ -0,0 +1,8 @@
{pkgs, ...}: let
hakase-hyprlock-text-generator = pkgs.writeShellScriptBin "hakase-hyprlock-text-generator" ''
'';
in {
home.packages = [
];
}
+57
View File
@@ -1,3 +1,60 @@
{pkgs, ...}: let
hakase-hyprlock-typewriter = pkgs.writeShellScriptBin "hakase-hyprlock-typewriter" ''
text="$1"
if [[ -z "$text" ]]; then
echo "Usage: $(basename "$0") [text]"
exit 1
fi
state_file="''${XDG_RUNTIME_DIR:-/tmp}/typewriter_pos"
blink_file="''${XDG_RUNTIME_DIR:-/tmp}/typewriter_blink"
pid_file="''${XDG_RUNTIME_DIR:-/tmp}/typewriter_pid"
current_pid=$(pgrep -x hyprlock | head -1)
if [[ -f $pid_file ]]; then
old_pid=$(cat $pid_file)
if [[ "''${old_pid}" != "''${current_pid}" ]]; then
rm -f "$state_file" "$blink_file"
fi
fi
echo "$current_pid" >"$pid_file"
if [[ ! -f $state_file ]]; then
echo 0 >"$state_file"
fi
if [[ ! -f $blink_file ]]; then
echo 0 >"$blink_file"
fi
len=''${#text}
letter=$(cat "$state_file")
blink=$(cat "$blink_file")
if [[ $letter -lt $len ]]; then
letter=$((letter + 1))
echo "$letter" >"$state_file"
echo "''${text:0:$letter}_"
else
# Toggle every 4 calls (at 200ms update = ~800ms blink)
if (((blink / 20) % 2 == 0)); then
echo "''${text}_"
else
echo "''${text}<span alpha=\"1%\">_</span>"
fi
fi
blink=$((blink + 1))
echo "$blink" >"$blink_file"
'';
hakase-test-hyprlock-typewriter = pkgs.writeShellScriptBin "hakase-test-hyprlock-typewriter" ''
for i in {1..10}; do
hakase-hyprlock-typewriter
done
'';
in {
home.packages = [
hakase-hyprlock-typewriter
hakase-test-hyprlock-typewriter
];
}