add(hyprlock): added typewriter animtaion
This commit is contained in:
+16
-11
@@ -6,6 +6,9 @@
|
||||
cacheWallpaper = "${config.home.homeDirectory}/.cache/current_wallpaper";
|
||||
clockFont = "JetBrains Mono";
|
||||
in {
|
||||
imports = [
|
||||
./scripts/typewriter.nix
|
||||
];
|
||||
programs.hyprlock = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
@@ -26,17 +29,6 @@ in {
|
||||
vibrancy = 0.2
|
||||
}
|
||||
|
||||
# Typewriter greeting (above clock)
|
||||
label {
|
||||
monitor =
|
||||
text = Hello World!
|
||||
color = $on_surface_variant
|
||||
font_size = 24
|
||||
font_family = ${clockFont} Bold
|
||||
position = 0, 200
|
||||
halign = center
|
||||
valign = center
|
||||
}
|
||||
|
||||
# Hours (top)
|
||||
label {
|
||||
@@ -111,6 +103,19 @@ in {
|
||||
fail_timeout = 2000
|
||||
fail_transition = 300
|
||||
}
|
||||
|
||||
# Typewriter greeting (above clock)
|
||||
label {
|
||||
monitor =
|
||||
text = cmd[update:50] hakase-hyprlock-typewriter 'They do be like that, huh?'
|
||||
color = $on_surface_variant
|
||||
font_size = 24
|
||||
font_family = ${clockFont} Bold
|
||||
position = 0, 200
|
||||
halign = center
|
||||
valign = center
|
||||
}
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{pkgs, ...}: let
|
||||
hakase-hyprlock-text-generator = pkgs.writeShellScriptBin "hakase-hyprlock-text-generator" ''
|
||||
|
||||
'';
|
||||
in {
|
||||
home.packages = [
|
||||
];
|
||||
}
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# flow
|
||||
# REPEATS via cmd[]. DESIGNED FOR HYPRLOCK SCRIPTING.
|
||||
# check if file exists. If not, create.
|
||||
# read the files
|
||||
# assign variables to read files
|
||||
# if letter is less than the word letters count, increment by 1, append the letter, and echo the result.
|
||||
# other than that, proceed to blinking stage.
|
||||
|
||||
text="Gamer"
|
||||
state_file="${XDG_RUNTIME_DIR:-/tmp}/typewriter_pos"
|
||||
blink_file="${XDG_RUNTIME_DIR:-/tmp}/typewriter_blink"
|
||||
|
||||
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}_"
|
||||
sleep 0.2
|
||||
else
|
||||
if ((blink % 2 == 0)); then
|
||||
echo "${text}_"
|
||||
else
|
||||
echo "${text} "
|
||||
fi
|
||||
sleep 1.1
|
||||
fi
|
||||
|
||||
blink=$((blink + 1))
|
||||
echo "$blink" >"$blink_file"
|
||||
Executable
Reference in New Issue
Block a user