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:
parent
14a94a4ece
commit
feafe252dc
5 changed files with 43 additions and 0 deletions
11
README.md
11
README.md
|
|
@ -73,6 +73,17 @@ ln -s ~/Projects/hypr-dotfiles/kitty kitty
|
|||
ln -s ~/Projects/hypr-dotfiles/helix helix
|
||||
```
|
||||
|
||||
To enable the auto-mute/unmute timers (mutes at 21:00, unmutes at
|
||||
07:00, only when idle-inhibit is active), link the systemd user units:
|
||||
|
||||
```
|
||||
systemctl --user link ~/Projects/hypr-dotfiles/systemd/user/auto-mute.service
|
||||
systemctl --user link ~/Projects/hypr-dotfiles/systemd/user/auto-mute.timer
|
||||
systemctl --user link ~/Projects/hypr-dotfiles/systemd/user/auto-unmute.service
|
||||
systemctl --user link ~/Projects/hypr-dotfiles/systemd/user/auto-unmute.timer
|
||||
systemctl --user enable --now auto-mute.timer auto-unmute.timer
|
||||
```
|
||||
|
||||
You also need to install all the dependencies:
|
||||
|
||||
- hyprland
|
||||
|
|
|
|||
7
systemd/user/auto-mute.service
Normal file
7
systemd/user/auto-mute.service
Normal 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
|
||||
9
systemd/user/auto-mute.timer
Normal file
9
systemd/user/auto-mute.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Mute audio at 21:00
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 21:00:00
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
7
systemd/user/auto-unmute.service
Normal file
7
systemd/user/auto-unmute.service
Normal 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
|
||||
9
systemd/user/auto-unmute.timer
Normal file
9
systemd/user/auto-unmute.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Unmute audio at 07:00
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 07:00:00
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue