Added support for both X11 and Wayland environments: Display Server Detection: - Auto-detects Wayland via WAYLAND_DISPLAY environment variable - Falls back to X11 commands if not Wayland - Works seamlessly on both display servers Wayland-specific tools: - wlopm - Wayland output power management (keeps display on) - wlr-randr - Output management for wlroots compositors - ydotool - Mouse movement for Wayland (alternative to xdotool) - systemd-inhibit integration for idle prevention Enhanced display keep-alive script: - Detects display server type on startup - Uses appropriate commands based on environment - Wayland: wlopm, wlr-randr, ydotool - X11: xset, xdotool, xrandr - Both: tvservice for HDMI power control App-level improvements (main.py): - Detects Wayland via os.environ check - Executes Wayland-specific commands when detected - Maintains X11 compatibility for older systems Installation improvements: - Auto-installs Wayland tools if Wayland is detected - Attempts to install: wlopm, wlr-randr, ydotool - Graceful fallback if packages unavailable This ensures HDMI power management works correctly on: - Raspberry Pi OS with X11 (older versions) - Raspberry Pi OS with Wayland (Bookworm and newer) - Any Linux system using either display server
34 lines
971 B
Bash
Executable File
34 lines
971 B
Bash
Executable File
#!/bin/bash
|
|
# Aggressive display keep-alive for Raspberry Pi
|
|
# Prevents HDMI from powering down
|
|
|
|
DISPLAY_TIMEOUT=30
|
|
|
|
while true; do
|
|
# Keep HDMI powered on (tvservice command)
|
|
if command -v tvservice &> /dev/null; then
|
|
/usr/bin/tvservice -p 2>/dev/null
|
|
fi
|
|
|
|
# Disable screensaver
|
|
if command -v xset &> /dev/null; then
|
|
DISPLAY=:0 xset s off 2>/dev/null
|
|
DISPLAY=:0 xset -dpms 2>/dev/null
|
|
DISPLAY=:0 xset dpms force on 2>/dev/null
|
|
DISPLAY=:0 xset s reset 2>/dev/null
|
|
fi
|
|
|
|
# Move mouse to trigger activity
|
|
if command -v xdotool &> /dev/null; then
|
|
DISPLAY=:0 xdotool mousemove_relative 1 1 2>/dev/null
|
|
DISPLAY=:0 xdotool mousemove_relative -1 -1 2>/dev/null
|
|
fi
|
|
|
|
# Disable monitor power saving
|
|
if command -v xrandr &> /dev/null; then
|
|
DISPLAY=:0 xrandr --output HDMI-1 --power-profile performance 2>/dev/null || true
|
|
fi
|
|
|
|
sleep $DISPLAY_TIMEOUT
|
|
done
|