Add screensaver inhibition control service

The service enables or disables swayidle inhibition depending on
whether any audio plays or not. It replaces the activation of
inhibition for fullscreen browser windows.
This commit is contained in:
Alexander Oakman 2024-07-20 22:50:52 +03:00
parent b4cef4847a
commit 9c4aaa4207
3 changed files with 23 additions and 15 deletions

View file

@ -45,21 +45,6 @@ for_window [title="Confirm to replace files"] move position center
for_window [title="Choose an Application"] floating enable for_window [title="Choose an Application"] floating enable
for_window [title="Removable medium is inserted"] floating enable for_window [title="Removable medium is inserted"] floating enable
# apply mark for Xwayland and wayland native browser windows
for_window [class="Chromium-browser"] mark Browser
for_window [class="Brave-browser"] mark Browser
for_window [class="firefox"] mark Browser
for_window [class="librewolf"] mark Browser
for_window [app_id="Chromium-browser"] mark Browser
for_window [app_id="brave-browser"] mark Browser
for_window [app_id="[Ff]irefox"] mark Browser
for_window [app_id="[Ll]ibrewolf"] mark Browser
# inhibit scrensaver for fullscreen browser windows
for_window [con_mark="Browser"] {
inhibit_idle fullscreen
}
# Don't allow applications to inhibit shortcuts, i.e. grab total control of the # Don't allow applications to inhibit shortcuts, i.e. grab total control of the
# keyboard. Chrome currently abuses this by enabling it for all "--app=..." # keyboard. Chrome currently abuses this by enabling it for all "--app=..."
# shortcuts. # shortcuts.

View file

@ -0,0 +1,12 @@
[Unit]
Description=Toggle idle inhibition depending on whether the audio is playing or not
PartOf=swayidle.service
After=swayidle.service
[Service]
ExecStart=/usr/share/sway/scripts/idle-inhibitor.sh
Restart=always
RestartSec=30
[Install]
WantedBy=sway-session.target

View file

@ -0,0 +1,11 @@
#!/bin/bash
set -e
if grep -s -l -v "closed" /proc/asound/card*/pcm*/sub*/status; then
swaymsg inhibit_idle open
printf "Idle inhibition is ON."
else
swaymsg inhibit_idle none
printf "Idle inhibition is OFF."
fi