Major rewrite of the runtime so the entry point is a proper gum TUI
instead of zenity dialogs, plus a handful of correctness fixes that
make it work on real Omarchy setups.
Runtime (motion-wallpaper-toggle, extracted from the installer heredoc):
* Full gum TUI: status header, monitor picker (with All monitors),
library / filesystem pickers, change-video, autostart toggle.
* State file at ~/.config/motion-wallpaper/state remembers last
video, target monitor, and last-used directory so Browse reopens
where the user was.
* Actions: toggle | start | stop | change | status.
Autostart:
* Ships a systemd user unit (motion-wallpaper.service).
* First fresh start prompts the user via gum confirm to enable it.
* Running-state menu offers a Turn autostart ON/OFF entry.
* Header shows the current autostart state.
Auto-pause:
* mpvpaper's -p is unreliable on Hyprland 0.54.x, so a small
motion-wallpaper-watcher subscribes to Hyprland's socket2 and
toggles mpv pause/resume via --input-ipc-server on fullscreen
enter/exit. Started/stopped alongside mpvpaper.
Omarchy compatibility:
* Stop path now respawns swaybg pointed at
~/.config/omarchy/current/background via setsid uwsm-app (the way
Omarchy autostarts it), instead of execing hyprpaper which isn't
present. Falls back to hyprpaper on non-Omarchy Hyprland setups.
* mpvpaper is launched under setsid uwsm-app so it survives the
Walker-spawned terminal closing.
Install / UX:
* Installer only invokes sudo/yay when packages are actually
missing, so reinstall is quiet.
* Dropped zenity; added gum + socat + libnotify.
* Custom SVG icon in the hicolor theme so Walker shows a proper
tile. Installer restarts elephant.service so the new entry/icon
appear without logout.
* .desktop flipped to Terminal=true so launchers spawn a terminal
for the TUI.
* Watcher lookup falls back to the script's own dir when PATH is
minimal (launcher-spawned terminals).
Bug fixes:
* Monitor picker was sending row-major data to zenity as one cell;
fixed (kept the correct form for the new gum picker).
* load_state / action_status no longer leak a non-zero exit code
from trailing test expressions.
* Stop path cleans up stray hyprpaper that would otherwise win the
background layer.
63 lines
2 KiB
Bash
63 lines
2 KiB
Bash
#!/usr/bin/env bash
|
|
# ==============================================================================
|
|
# Motion Wallpaper — auto-pause watcher.
|
|
#
|
|
# Subscribes to Hyprland's event socket (socket2) and toggles mpv pause/resume
|
|
# via the IPC socket that mpvpaper was started with. Replaces mpvpaper's own
|
|
# --auto-pause / -p flag, which is unreliable on recent Hyprland releases.
|
|
#
|
|
# This script runs as a background sibling to mpvpaper. The main toggle script
|
|
# starts it and kills it.
|
|
# ==============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
|
MPV_IPC="$RUNTIME_DIR/motion-wallpaper-mpv.sock"
|
|
LOG_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/motion-wallpaper.log"
|
|
|
|
log() {
|
|
printf '[%s] watcher: %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" >> "$LOG_FILE"
|
|
}
|
|
|
|
if [ -z "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]; then
|
|
log "HYPRLAND_INSTANCE_SIGNATURE not set — exiting"
|
|
exit 0
|
|
fi
|
|
|
|
HYPR_SOCK="$RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
|
|
if [ ! -S "$HYPR_SOCK" ]; then
|
|
log "hyprland event socket not found ($HYPR_SOCK) — exiting"
|
|
exit 0
|
|
fi
|
|
|
|
if ! command -v socat >/dev/null 2>&1; then
|
|
log "socat not installed — exiting"
|
|
exit 0
|
|
fi
|
|
|
|
send_mpv() {
|
|
# Best-effort — silently no-op if mpv's IPC socket isn't up yet.
|
|
[ -S "$MPV_IPC" ] || return 0
|
|
printf '%s\n' "$1" | socat - "UNIX-CONNECT:$MPV_IPC" >/dev/null 2>&1 || true
|
|
}
|
|
|
|
pause_mpv() { send_mpv '{ "command": ["set_property", "pause", true] }'; }
|
|
resume_mpv() { send_mpv '{ "command": ["set_property", "pause", false] }'; }
|
|
|
|
log "watching $HYPR_SOCK"
|
|
|
|
# Hyprland socket2 emits newline-separated "EVENT>>DATA" lines. We only care
|
|
# about the fullscreen state. `fullscreen>>1` = entered, `fullscreen>>0` = left.
|
|
socat -u "UNIX-CONNECT:$HYPR_SOCK" - | while IFS= read -r line; do
|
|
case "$line" in
|
|
fullscreen\>\>1)
|
|
log "fullscreen entered — pause"
|
|
pause_mpv
|
|
;;
|
|
fullscreen\>\>0)
|
|
log "fullscreen left — resume"
|
|
resume_mpv
|
|
;;
|
|
esac
|
|
done
|