mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Turns out there are control codes for tracking mouse actions in xterm-compatible terminal emulators (mind blown). This patch adds mouse action awareness to our beloved screensaver setup: - on setup it sends the respective control codes for movement and click detection - in the main loop it opens up the input reader to read raw bytes and, thus, enable to detect even so much as a mouse's squeak Personally, I love swiping my trackpad to exit screensaver. But the explicit pressing-a-key to exit is nice, also. And I don't know if many people have jitter issues with their mouses or trackpads. Reckon, if they had they wouldn't get to see the glory that TTE is anyway, ever :) This is tested and working in Ghostty. Sorry for the low-effort testing.
35 lines
1.0 KiB
Bash
Executable File
35 lines
1.0 KiB
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 '\e[?1000h\e[?1003h' # Enable mouse tracking (clicks: 1000, movement: 1003)
|
|
while read -rsn1 -t 0.1; do :; done # Flush any pending input
|
|
|
|
printf '\033]11;rgb:00/00/00\007' # Set background color to black
|
|
|
|
hyprctl keyword cursor:invisible true &>/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 -x tte >/dev/null; do
|
|
if read -rsn1 -t 1 || ! screensaver_in_focus; then
|
|
exit_screensaver
|
|
fi
|
|
done
|
|
done
|