From 7a5c811ec7cd31e231304e1f58d9068430d749ad Mon Sep 17 00:00:00 2001 From: kenji Date: Sat, 3 Jan 2026 09:14:52 -0600 Subject: [PATCH] fix(screensaver): finally works --- apps/ghostty/default.nix | 26 +++++++++++++++----------- apps/hyprland/hypr/rules.nix | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/ghostty/default.nix b/apps/ghostty/default.nix index 65a1579..ca7fc12 100644 --- a/apps/ghostty/default.nix +++ b/apps/ghostty/default.nix @@ -5,33 +5,37 @@ }: { home.packages = [ (pkgs.writeShellScriptBin "tte-loop" '' - trap 'tput cnorm; exit 0' INT - tput civis + trap 'printf "\e[?25h"; exit 0' INT + printf '\e[?25l' effects=(beams binarypath blackhole bouncyballs bubbles burn colorshift crumble decrypt errorcorrect expand fireworks highlight laseretch matrix middleout orbittingvolley overflow pour print rain randomsequence rings scattered slice slide spotlights spray swarm sweep synthgrid unstable vhstape waves wipe) while true; do clear cols=$(tput cols) lines=$(tput lines) effect="''${effects[RANDOM % ''${#effects[@]}]}" + printf '\e[?25l' ${pkgs.terminaltexteffects}/bin/tte --input-file ${config.home.homeDirectory}/.config/nixos/assets/branding.txt --anchor-canvas c --anchor-text c --canvas-width "$cols" --canvas-height "$((lines-1))" --frame-rate 120 "$effect" - tput civis + printf '\e[?25l' sleep 2 done '') (pkgs.writeShellScriptBin "tte-screensaver" '' - # Start ghostty in background - ${pkgs.ghostty}/bin/ghostty --config-file=${config.home.homeDirectory}/.config/ghostty/screensaver --fullscreen -e tte-loop & - ghostty_pid=$! + # Get all monitors + monitors=$(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[].name') - # Wait a moment for ghostty to start - sleep 0.5 + # Launch ghostty on each monitor one at a time + for monitor in $monitors; do + ${pkgs.hyprland}/bin/hyprctl dispatch focusmonitor "$monitor" + sleep 0.3 + ${pkgs.ghostty}/bin/ghostty --config-file=${config.home.homeDirectory}/.config/ghostty/screensaver --fullscreen -e tte-loop & + sleep 1 + done # Monitor for any input and exit when detected ${pkgs.libinput}/bin/libinput debug-events 2>/dev/null | head -n 1 >/dev/null - # Input detected, kill ghostty - kill $ghostty_pid 2>/dev/null - wait $ghostty_pid 2>/dev/null + # Input detected, kill all screensaver instances + ${pkgs.procps}/bin/pkill -f "ghostty.*tte-loop" '') ]; diff --git a/apps/hyprland/hypr/rules.nix b/apps/hyprland/hypr/rules.nix index 7925a36..06612fb 100644 --- a/apps/hyprland/hypr/rules.nix +++ b/apps/hyprland/hypr/rules.nix @@ -58,6 +58,7 @@ "float, class:^(org\.gnome\.Loupe)$" "center, class:^(org\.gnome\.Loupe)$" "size 70% 70%, class:^(org\.gnome\.Loupe)$" + ]; }; }