Files
omarchy/bin/omarchy-cmd-screensaver
David Heinemeier Hansson d2ea6ad183 Canceling the screensaver on mouse movement doesn't work with bluetooth mice
Could not get it to stop existing with a Logitech MX4 when connected via
bluetooth.
2025-12-17 15:04:10 -08:00

35 lines
950 B
Bash
Executable File

#!/bin/bash
screensaver_in_focus() {
hyprctl activewindow -j | jq -e '.class == "org.omarchy.screensaver"' >/dev/null 2>&1
}
exit_screensaver() {
hyprctl keyword cursor:invisible false
pkill -x tte 2>/dev/null
pkill -f org.omarchy.screensaver 2>/dev/null
exit 0
}
# Exit the screensaver on signals and input from keyboard and mouse
trap exit_screensaver SIGINT SIGTERM SIGHUP SIGQUIT
printf '\033]11;rgb:00/00/00\007' # Set background color to black
hyprctl keyword cursor:invisible true &>/dev/null
tty=$(tty 2>/dev/null)
while true; do
tte -i ~/.config/omarchy/branding/screensaver.txt \
--frame-rate 120 --canvas-width 0 --canvas-height 0 --reuse-canvas --anchor-canvas c --anchor-text c\
--random-effect --exclude-effects dev_worm \
--no-eol --no-restore-cursor &
while pgrep -t "${tty#/dev/}" -x tte >/dev/null; do
if read -n1 -t 1 || ! screensaver_in_focus; then
exit_screensaver
fi
done
done