From 8235201167512e92ede062fdc23ef5efd55b3526 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 18 May 2024 14:42:40 +0200 Subject: [PATCH] Revert "music: replace Spotify by Deezer" This reverts commit 7086a909cfc4cdc2cd54f1d963d129125be7760d. --- bin/i3-companion | 1 - bin/rofi-mediaplayer | 4 ++-- bin/spotify-clean | 9 +++++++++ config | 2 +- dotfiles/systemd/spotify-clean.service | 9 +++++++++ dotfiles/systemd/spotify-clean.timer | 7 +++++++ dotfiles/systemd/xsession.target | 1 + 7 files changed, 29 insertions(+), 4 deletions(-) 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/i3-companion b/bin/i3-companion index 7f130ec..b82a6cb 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -48,7 +48,6 @@ application_icons = { "chromium": icon(3, ""), "d-feet": icon(2, ""), "darktable": icon(2, ""), - "deezer": icon(3, ""), "discord": icon(3, ""), "draw.io": icon(2, ""), "easyeffects": icon(2, ""), diff --git a/bin/rofi-mediaplayer b/bin/rofi-mediaplayer index b4eb241..81b1ae5 100755 --- a/bin/rofi-mediaplayer +++ b/bin/rofi-mediaplayer @@ -45,7 +45,7 @@ media-playback-stop Stop go-next Next track audio-input-microphone Toggle microphone multimedia-volume-control Open mixer panel -dev.aunetx.deezer Open Deezer +com.spotify.Client Open Spotify EOF # Player status @@ -68,7 +68,7 @@ EOF 5) $playerctl next ;; 6) ~/.config/i3/bin/toggle-mute source ;; 7) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;; - 8) i3-msg '[class="Deezer"] focus' || i3-msg exec gtk-launch dev.aunetx.deezer ;; + 8) i3-msg '[class="Spotify"] focus' || i3-msg exec gtk-launch com.spotify.Client ;; esac >&2 ;; esac diff --git a/bin/spotify-clean b/bin/spotify-clean new file mode 100755 index 0000000..dd8dae3 --- /dev/null +++ b/bin/spotify-clean @@ -0,0 +1,9 @@ +#!/bin/sh + +# Kill all spotify streams, except the most recent one. We need to use +# the serial to know which one this is as ID are not monotonous. + +pw-dump \ + | jq '.[]|select(.type == "PipeWire:Interface:Client" and .info.props."application.name" == "spotify").id' \ + | head -n-1 \ + | xargs -trn1 pw-cli destroy diff --git a/config b/config index 742e3c7..370a88f 100644 --- a/config +++ b/config @@ -6,7 +6,7 @@ set $down k set $left j set $right semicolon set $term vbeterm -set $mediaplayer chromium.instance3 +set $mediaplayer spotify set $borderpx 3 font pango:Iosevka Aile 9 diff --git a/dotfiles/systemd/spotify-clean.service b/dotfiles/systemd/spotify-clean.service new file mode 100644 index 0000000..3214b32 --- /dev/null +++ b/dotfiles/systemd/spotify-clean.service @@ -0,0 +1,9 @@ +[Unit] +Description=Cleaner for Spotify extra PulseAudio streams +After=sound.target + +[Service] +ExecStart=%h/.config/i3/bin/spotify-clean +Type=oneshot +RemainAfterExit=false +TimeoutStartSec=5s 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 61e1594..dee8f2a 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