diff --git a/README.md b/README.md index a4014db..770f5b8 100644 --- a/README.md +++ b/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 diff --git a/systemd/user/auto-mute.service b/systemd/user/auto-mute.service new file mode 100644 index 0000000..811b7b4 --- /dev/null +++ b/systemd/user/auto-mute.service @@ -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 diff --git a/systemd/user/auto-mute.timer b/systemd/user/auto-mute.timer new file mode 100644 index 0000000..ddcd649 --- /dev/null +++ b/systemd/user/auto-mute.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Mute audio at 21:00 + +[Timer] +OnCalendar=*-*-* 21:00:00 +Persistent=false + +[Install] +WantedBy=timers.target diff --git a/systemd/user/auto-unmute.service b/systemd/user/auto-unmute.service new file mode 100644 index 0000000..c00d1a0 --- /dev/null +++ b/systemd/user/auto-unmute.service @@ -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 diff --git a/systemd/user/auto-unmute.timer b/systemd/user/auto-unmute.timer new file mode 100644 index 0000000..e0a57c5 --- /dev/null +++ b/systemd/user/auto-unmute.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Unmute audio at 07:00 + +[Timer] +OnCalendar=*-*-* 07:00:00 +Persistent=false + +[Install] +WantedBy=timers.target