dwm-bar for archlinux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

38 lines
1.1 KiB

#!/bin/sh
# A dwm_bar function that shows the current artist, track, duration, and status from Spotify using playerctl
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: spotify, playerctl
# TODO: Find a method to get track position data and shuffle status (currently playerctl does not work for this)
dwm_spotify () {
if ps -C spotify > /dev/null; then
ARTIST=$(playerctl -p spotify metadata artist)
TRACK=$(playerctl -p spotify metadata title)
DURATION=$(playerctl -p spotify metadata mpris:length | sed 's/.\{6\}$//')
STATUS=$(playerctl -p spotify status)
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$STATUS" = "Playing" ]; then
STATUS="▶"
else
STATUS="⏸"
fi
else
if [ "$STATUS" = "Playing" ]; then
STATUS="PLA"
else
STATUS="PAU"
fi
fi
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK"
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
printf "%s\n" "$SEP2"
fi
}
dwm_spotify