Skip to content

feat(audio): prevent idle sleep during active audio playback - #9768

Open
edgseu wants to merge 3 commits into
omacom:quattrofrom
edgseu:feat-audio-playback-inhibit
Open

feat(audio): prevent idle sleep during active audio playback#9768
edgseu wants to merge 3 commits into
omacom:quattrofrom
edgseu:feat-audio-playback-inhibit

Conversation

@edgseu

@edgseu edgseu commented Sep 2, 2026

Copy link
Copy Markdown

Summary

When media or audio is playing in applications that do not directly manage Wayland idle inhibitor protocols (such as background music streams, certain web browsers, podcasts, terminal music players, or games), Omarchy's idle screensaver and session lock can trigger while audio is actively playing.

This PR adds an automatic audio-aware idle inhibitor daemon that keeps the system awake during active playback while strictly honoring user intent and display-off preferences.

Features

  • Event-Driven Audio Monitoring: Subscribes to PulseAudio/PipeWire sink-input events (pactl subscribe) to immediately detect when audio playback starts and stops without CPU-intensive polling loops.
  • Stay-Awake Coordination:
    • Automatically claims Omarchy's stay-awake indicator state ($HOME/.local/state/omarchy/indicators/stay-awake) when an unmuted, uncorked audio stream is active.
    • Automatically releases the indicator when all audio streams are paused/stopped.
  • Stream-Scoped User Dismissal (User Intent Always Wins):
    • If the user explicitly disables the stay-awake indicator (via the top bar widget or menu) while audio is playing, the daemon records a session suppression marker and will not re-assert stay-awake for the remainder of that continuous playback.
    • The suppression marker automatically resets when audio playback ends, so subsequent media sessions automatically receive sleep protection again.
  • Session Lock & Display Sleep Cooperation:
    • When the session is locked (omarchy-hyprland-session-locked / SUPER + L), the inhibitor automatically yields so DPMS can turn off the display while audio continues playing seamlessly in the background.
  • Systemd User Service: Ships omarchy-audio-inhibit.service enabled on graphical-session.target.

Changes

  • bin/omarchy-audio-inhibit: Lightweight event-driven daemon with ownership tracking, user-dismissal suppression, and --status / --once CLI inspection modes.
  • default/systemd/user/omarchy-audio-inhibit.service: Systemd user service unit running under graphical sessions.
  • install/user/first-run/enable-user-units.sh: Enabled during first-run user setup.
  • test/shell.d/audio-inhibit-test.sh: Automated unit test suite verifying stream detection, stay-awake ownership, user-dismissal suppression, session lock release, and automatic reset on playback end.

Verification

  • Automated unit test suite test/shell.d/audio-inhibit-test.sh passes (8/8 assertions).
  • Automated CLI test suite ./test/cli passes (107/107 assertions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant