mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Make screensaver work with xdg-terminal-exec
This commit is contained in:
@@ -1,22 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
screensaver_in_focus() {
|
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() {
|
exit_screensaver() {
|
||||||
|
# Clear and reset terminal
|
||||||
|
printf '\033[2J\033[H\033[0m'
|
||||||
hyprctl keyword cursor:invisible false
|
hyprctl keyword cursor:invisible false
|
||||||
pkill -x tte 2>/dev/null
|
pkill -x tte 2>/dev/null
|
||||||
pkill -f "alacritty --class Screensaver" 2>/dev/null
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
trap exit_screensaver SIGINT SIGTERM SIGHUP SIGQUIT
|
trap exit_screensaver SIGINT SIGTERM SIGHUP SIGQUIT
|
||||||
|
|
||||||
|
# Set background and cursor colors using OSC escape sequences
|
||||||
|
printf '\033]11;rgb:00/00/00\007' # Background color to black
|
||||||
|
printf '\033]12;rgb:00/00/00\007' # Cursor color to black
|
||||||
|
|
||||||
|
# Clear screen and fill with black background
|
||||||
|
printf '\033[48;2;0;0;0m\033[2J\033[H'
|
||||||
|
|
||||||
hyprctl keyword cursor:invisible true &>/dev/null
|
hyprctl keyword cursor:invisible true &>/dev/null
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
effect=$(tte 2>&1 | grep -oP '{\K[^}]+' | tr ',' ' ' | tr ' ' '\n' | sed -n '/^beams$/,$p' | sort -u | shuf -n1)
|
effect=$(tte 2>&1 | grep -oP '{\K[^}]+' | tr ',' ' ' | tr ' ' '\n' | sed -n '/^beams$/,$p' | sort -u | shuf -n1)
|
||||||
|
|
||||||
tte -i ~/.config/omarchy/branding/screensaver.txt \
|
tte -i ~/.config/omarchy/branding/screensaver.txt \
|
||||||
--frame-rate 240 --canvas-width 0 --canvas-height 0 --anchor-canvas c --anchor-text c --no-eol \
|
--frame-rate 240 --canvas-width 0 --canvas-height 0 --anchor-canvas c --anchor-text c --no-eol \
|
||||||
"$effect" &
|
"$effect" &
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ if ! command -v tte &>/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit early if screensave is already running
|
# Exit early if screensaver is already running
|
||||||
pgrep -f "alacritty --class Screensaver" && exit 0
|
pgrep -f "omarchy-cmd-screensaver" && exit 0
|
||||||
|
|
||||||
# Allow screensaver to be turned off but also force started
|
# Allow screensaver to be turned off but also force started
|
||||||
if [[ -f ~/.local/state/omarchy/toggles/screensaver-off ]] && [[ $1 != "force" ]]; then
|
if [[ -f ~/.local/state/omarchy/toggles/screensaver-off ]] && [[ $1 != "force" ]]; then
|
||||||
@@ -18,11 +18,9 @@ focused=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true).name')
|
|||||||
for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
|
for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||||
hyprctl dispatch focusmonitor $m
|
hyprctl dispatch focusmonitor $m
|
||||||
|
|
||||||
# FIXME: Find a way to make this generic where we it can work for kitty + ghostty
|
|
||||||
hyprctl dispatch exec -- \
|
hyprctl dispatch exec -- \
|
||||||
alacritty --class Screensaver \
|
xdg-terminal-exec --app-id=com.omarchy.screensaver \
|
||||||
--config-file ~/.local/share/omarchy/default/alacritty/screensaver.toml \
|
omarchy-cmd-screensaver
|
||||||
-e omarchy-cmd-screensaver
|
|
||||||
done
|
done
|
||||||
|
|
||||||
hyprctl dispatch focusmonitor $focused
|
hyprctl dispatch focusmonitor $focused
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ windowrule = tag +floating-window, class:(xdg-desktop-portal-gtk|sublime_text|De
|
|||||||
windowrule = float, class:org.gnome.Calculator
|
windowrule = float, class:org.gnome.Calculator
|
||||||
|
|
||||||
# Fullscreen screensaver
|
# Fullscreen screensaver
|
||||||
windowrule = fullscreen, class:Screensaver
|
windowrule = fullscreen, class:com.omarchy.screensaver
|
||||||
|
|
||||||
# No transparency on media windows
|
# 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)$
|
windowrule = opacity 1 1, class:^(zoom|vlc|mpv|org.kde.kdenlive|com.obsproject.Studio|com.github.PintaProject.Pinta|imv|org.gnome.NautilusPreviewer)$
|
||||||
|
|||||||
Reference in New Issue
Block a user