vincentbernat.i3wm-configur.../bin/spotify-clean

16 lines
428 B
Text
Raw Normal View History

#!/bin/sh
2022-07-30 00:20:19 +02:00
# 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.
2022-06-30 21:22:43 +02:00
pw-cli dump short client \
| grep -F 'ap="spotify"' \
| cut -d: -f1 \
2022-07-30 00:20:19 +02:00
| while read id; do
echo $(pw-cli dump $id | sed -nE 's/^\s*object.serial = "([0-9]*)"/\1/p') $id
done \
| sort -n \
2022-07-30 09:20:55 +02:00
| cut -d' ' -f2 \
2022-07-30 00:20:19 +02:00
| head -n-1 \
| xargs -trn1 pw-cli destroy