Add systemd timers to auto-mute/unmute when idle-inhibit is active

Mutes audio at 21:00 and unmutes at 07:00, but only when the
idle-inhibit toggle is active (PID file exists). This is useful
for leaving the computer running overnight for SSH access while
keeping it quiet for sleeping.
This commit is contained in:
Jeena 2026-04-11 14:41:24 +00:00
parent 14a94a4ece
commit feafe252dc
5 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,7 @@
[Unit]
Description=Mute audio when idle-inhibit is active
[Service]
Type=oneshot
ExecCondition=/bin/bash -c 'test -f ${XDG_RUNTIME_DIR}/idle-inhibit.pid && kill -0 $(cat ${XDG_RUNTIME_DIR}/idle-inhibit.pid)'
ExecStart=/usr/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ 1

View file

@ -0,0 +1,9 @@
[Unit]
Description=Mute audio at 21:00
[Timer]
OnCalendar=*-*-* 21:00:00
Persistent=false
[Install]
WantedBy=timers.target

View file

@ -0,0 +1,7 @@
[Unit]
Description=Unmute audio when idle-inhibit is active
[Service]
Type=oneshot
ExecCondition=/bin/bash -c 'test -f ${XDG_RUNTIME_DIR}/idle-inhibit.pid && kill -0 $(cat ${XDG_RUNTIME_DIR}/idle-inhibit.pid)'
ExecStart=/usr/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ 0

View file

@ -0,0 +1,9 @@
[Unit]
Description=Unmute audio at 07:00
[Timer]
OnCalendar=*-*-* 07:00:00
Persistent=false
[Install]
WantedBy=timers.target