82 lines
1.7 KiB
Nix
82 lines
1.7 KiB
Nix
{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"
|
||
"Habari"
|
||
"Hei"
|
||
"Hallå"
|
||
"Hei"
|
||
"Kamusta"
|
||
"Salam"
|
||
"Selamat"
|
||
"Saluton"
|
||
"Tere"
|
||
"Sveiki"
|
||
"Labas"
|
||
"Здраво"
|
||
"Здравей"
|
||
"Bok"
|
||
"Përshëndetje"
|
||
"Բdelays"
|
||
"გამარჯობა"
|
||
"Сайн уу"
|
||
"ສະບາຍດີ"
|
||
"ជំរាបសួរ"
|
||
"မင်္ဂလာပါ"
|
||
"ආයුබෝවන්"
|
||
)
|
||
|
||
idx=$((RANDOM % ''${#greetings[@]}))
|
||
greeting="''${greetings[$idx]}"
|
||
|
||
echo "$current_pid" > "$pid_file"
|
||
echo "$greeting" > "$cache_file"
|
||
echo "$greeting"
|
||
'';
|
||
in {
|
||
home.packages = [
|
||
hakase-hyprlock-text-generator
|
||
];
|
||
}
|