Files
nixos/apps/hyprlock/scripts/random-text.nix
T
2026-01-10 23:18:41 -06:00

116 lines
2.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{pkgs, ...}: let
hakase-hyprlock-text-generator = pkgs.writeShellScriptBin "hakase-hyprlock-text-generator" ''
cache_file="''${XDG_RUNTIME_DIR:-/tmp}/hyprlock_greeting"
pid_file="''${XDG_RUNTIME_DIR:-/tmp}/hyprlock_greeting_pid"
current_pid=$(pgrep -x hyprlock | head -1)
# Pick new greeting only when hyprlock restarts
if [[ -f $pid_file && -f $cache_file ]]; then
old_pid=$(cat "$pid_file")
if [[ "$old_pid" == "$current_pid" ]]; then
cat "$cache_file"
exit 0
fi
fi
greetings=(
"Hello"
"Hola"
"Bonjour"
"Hallo"
"Ciao"
"Olá"
"Привет"
""
""
""
"مرحبا"
"שלום"
""
""
"Γειά σου"
"Merhaba"
"Xin chào"
"Cześć"
"Hej"
"Ahoj"
"Szia"
"Salut"
"Привіт"
""
""
"Jambo"
"Aloha"
"Sawubona"
"Hei"
"Hallå"
"Kamusta"
"Salam"
"Selamat"
"Saluton"
"Tere"
"Sveiki"
"Labas"
"Здраво"
"Здравей"
"Bok"
"Përshëndetje"
"Բարև"
""
"Сайн уу"
""
""
""
""
"Dia dhuit"
"Halò"
"Shwmae"
"Hoi"
"Halló"
"Kaixo"
"Bon dia"
"Ola"
"Ħello"
"ਿ "
" "
""
""
""
""
""
"Bawo"
"Ndeewo"
"Sannu"
"Iska warran"
"Kia ora"
"Bula"
"Talofa"
"Mālō e lelei"
""
""
"Yá'át'ééh"
"Allinllachu"
"Mba'éichapa"
"Salve"
"Moien"
"Apa khabar"
"Сәлем"
"Assalomu alaykum"
"Slav"
""
)
idx=$((RANDOM % ''${#greetings[@]}))
greeting="''${greetings[$idx]}"
echo "$current_pid" > "$pid_file"
echo "$greeting" > "$cache_file"
echo "$greeting"
'';
in {
home.packages = [
hakase-hyprlock-text-generator
];
}