From 8cd2ed373013f1fc65c485ae7d46e1b4a27ac43a Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 30 Jun 2022 21:18:07 +0200 Subject: [PATCH] Revert "spotify: remove socket cleaning" This reverts commit 2e4e2d311cdae0e972ce7d3f4701969f4735d597. Problem is still here. --- bin/spotify-clean | 8 ++++++++ dotfiles/systemd/spotify-clean.service | 8 ++++++++ dotfiles/systemd/spotify-clean.timer | 7 +++++++ dotfiles/systemd/xsession.target | 1 + 4 files changed, 24 insertions(+) create mode 100755 bin/spotify-clean create mode 100644 dotfiles/systemd/spotify-clean.service create mode 100644 dotfiles/systemd/spotify-clean.timer diff --git a/bin/spotify-clean b/bin/spotify-clean new file mode 100755 index 0000000..924adb3 --- /dev/null +++ b/bin/spotify-clean @@ -0,0 +1,8 @@ +#!/bin/sh + +# Kill all spotify streams, except the most recent one. + +pactl list short clients \ + | awk '($3 == "spotify") {print $1}' \ + | head -n-1 \ + | xargs -rn1 pacmd kill-client diff --git a/dotfiles/systemd/spotify-clean.service b/dotfiles/systemd/spotify-clean.service new file mode 100644 index 0000000..190068c --- /dev/null +++ b/dotfiles/systemd/spotify-clean.service @@ -0,0 +1,8 @@ +[Unit] +Description=Clean spotify extra PulseAudio streams +After=sound.target + +[Service] +ExecStart=%h/.config/i3/bin/spotify-clean +Type=oneshot +RemainAfterExit=false diff --git a/dotfiles/systemd/spotify-clean.timer b/dotfiles/systemd/spotify-clean.timer new file mode 100644 index 0000000..2bd5c80 --- /dev/null +++ b/dotfiles/systemd/spotify-clean.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Timer for cleaning spotify extra PA streams +After=pulseaudio.socket + +[Timer] +OnUnitActiveSec=1h +OnStartupSec=1h diff --git a/dotfiles/systemd/xsession.target b/dotfiles/systemd/xsession.target index 097b562..5f7e58f 100644 --- a/dotfiles/systemd/xsession.target +++ b/dotfiles/systemd/xsession.target @@ -8,6 +8,7 @@ Wants=picom.service Wants=pipewire-pulse.socket Wants=policykit-agent.service Wants=redshift.service +Wants=spotify-clean.timer Wants=ssh-agent.service Wants=weather.timer Wants=wireplumber.service