Make screensaver capable of running in any of the terminal options

This commit is contained in:
David Heinemeier Hansson
2025-11-10 10:02:02 +01:00
parent 6f334868d6
commit c6918e637b
3 changed files with 28 additions and 9 deletions

View File

@@ -1,13 +1,13 @@
#!/bin/bash
screensaver_in_focus() {
hyprctl activewindow -j | jq -e '.class == "Screensaver"' >/dev/null 2>&1
hyprctl activewindow -j | jq -e '.class == "com.omarchy.Screensaver"' >/dev/null 2>&1
}
exit_screensaver() {
hyprctl keyword cursor:invisible false
pkill -x tte 2>/dev/null
pkill -f "alacritty --class Screensaver" 2>/dev/null
pkill -f com.omarchy.Screensaver 2>/dev/null
exit 0
}

View File

@@ -6,7 +6,7 @@ if ! command -v tte &>/dev/null; then
fi
# Exit early if screensave is already running
pgrep -f "alacritty --class Screensaver" && exit 0
pgrep -f com.omarchy.Screensaver && exit 0
# Allow screensaver to be turned off but also force started
if [[ -f ~/.local/state/omarchy/toggles/screensaver-off ]] && [[ $1 != "force" ]]; then
@@ -14,15 +14,34 @@ if [[ -f ~/.local/state/omarchy/toggles/screensaver-off ]] && [[ $1 != "force" ]
fi
focused=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true).name')
terminal=$(xdg-terminal-exec --print-id)
for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
hyprctl dispatch focusmonitor $m
# FIXME: Find a way to make this generic where we it can work for kitty + ghostty
hyprctl dispatch exec -- \
alacritty --class Screensaver \
--config-file ~/.local/share/omarchy/default/alacritty/screensaver.toml \
-e omarchy-cmd-screensaver
case $terminal in
*Alacritty*)
hyprctl dispatch exec -- \
alacritty --class=com.omarchy.Screensaver \
--config-file ~/.local/share/omarchy/default/alacritty/screensaver.toml \
-e omarchy-cmd-screensaver
;;
*ghostty*)
hyprctl dispatch exec -- \
ghostty --class=com.omarchy.Screensaver \
--font-size=18 \
-e omarchy-cmd-screensaver
;;
*kitty*)
hyprctl dispatch exec -- \
kitty --class=com.omarchy.Screensaver \
--override font_size=18 \
-e omarchy-cmd-screensaver
;;
*)
notify-send "✋ Screensaver only runs in Alacritty, Ghostty, or Kitty"
;;
esac
done
hyprctl dispatch focusmonitor $focused

View File

@@ -8,7 +8,7 @@ windowrule = tag +floating-window, class:(xdg-desktop-portal-gtk|sublime_text|De
windowrule = float, class:org.gnome.Calculator
# Fullscreen screensaver
windowrule = fullscreen, class:Screensaver
windowrule = fullscreen, class:com.omarchy.Screensaver
# No transparency on media windows
windowrule = opacity 1 1, class:^(zoom|vlc|mpv|org.kde.kdenlive|com.obsproject.Studio|com.github.PintaProject.Pinta|imv|org.gnome.NautilusPreviewer)$