|
@ -4,16 +4,24 @@ |
|
|
# Joe Standring <git@joestandring.com> |
|
|
# Joe Standring <git@joestandring.com> |
|
|
# GNU GPLv3 |
|
|
# GNU GPLv3 |
|
|
|
|
|
|
|
|
# Dependencies: spotify, playerctl |
|
|
|
|
|
|
|
|
# Dependencies: spotify/spotifyd, playerctl |
|
|
|
|
|
|
|
|
# TODO: Find a method to get track position data and shuffle status (currently playerctl does not work for this) |
|
|
|
|
|
|
|
|
# NOTE: The official spotify client does not provide the track position or shuffle status through playerctl. This does work through spotifyd however. |
|
|
|
|
|
|
|
|
dwm_spotify () { |
|
|
dwm_spotify () { |
|
|
if ps -C spotify > /dev/null; then |
|
|
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) |
|
|
|
|
|
|
|
|
PLAYER="spotify" |
|
|
|
|
|
elif ps -C spotifyd > /dev/null; then |
|
|
|
|
|
PLAYER="spotifyd" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$PLAYER" = "spotify" ] || [ "$PLAYER" = "spotifyd" ]; then |
|
|
|
|
|
ARTIST=$(playerctl metadata artist) |
|
|
|
|
|
TRACK=$(playerctl metadata title) |
|
|
|
|
|
POSITION=$(playerctl position | sed 's/..\{6\}$//') |
|
|
|
|
|
DURATION=$(playerctl metadata mpris:length | sed 's/.\{6\}$//') |
|
|
|
|
|
STATUS=$(playerctl status) |
|
|
|
|
|
SHUFFLE=$(playerctl shuffle) |
|
|
|
|
|
|
|
|
if [ "$IDENTIFIER" = "unicode" ]; then |
|
|
if [ "$IDENTIFIER" = "unicode" ]; then |
|
|
if [ "$STATUS" = "Playing" ]; then |
|
|
if [ "$STATUS" = "Playing" ]; then |
|
@ -21,17 +29,36 @@ dwm_spotify () { |
|
|
else |
|
|
else |
|
|
STATUS="⏸" |
|
|
STATUS="⏸" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$SHUFFLE" = "On" ]; then |
|
|
|
|
|
SHUFFLE=" 🔀" |
|
|
|
|
|
else |
|
|
|
|
|
SHUFFLE="" |
|
|
|
|
|
fi |
|
|
else |
|
|
else |
|
|
if [ "$STATUS" = "Playing" ]; then |
|
|
if [ "$STATUS" = "Playing" ]; then |
|
|
STATUS="PLA" |
|
|
STATUS="PLA" |
|
|
else |
|
|
else |
|
|
STATUS="PAU" |
|
|
STATUS="PAU" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$SHUFFLE" = "On" ]; then |
|
|
|
|
|
SHUFFLE=" S" |
|
|
|
|
|
else |
|
|
|
|
|
SHUFFLE="" |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" |
|
|
|
|
|
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) |
|
|
|
|
|
printf "%s\n" "$SEP2" |
|
|
|
|
|
|
|
|
if [ "$PLAYER" = "spotify" ]; then |
|
|
|
|
|
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" |
|
|
|
|
|
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) |
|
|
|
|
|
printf "%s\n" "$SEP2" |
|
|
|
|
|
else |
|
|
|
|
|
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" |
|
|
|
|
|
printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) |
|
|
|
|
|
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) |
|
|
|
|
|
printf "%s%s\n" "$SHUFFLE" "$SEP2" |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|