dotfiles/config/polybar/scripts/media/playing.sh

30 lines
481 B
Bash
Raw Permalink Normal View History

2023-02-06 17:56:36 -05:00
#! /bin/sh
MAX_SONG_LEN=45
MAX_ARTIST_LEN=30
song=$(playerctl metadata title 2>/dev/null)
if [ "$song" = "" ]
then
echo " "
exit
fi
short_song=$(echo $song | head -c $MAX_SONG_LEN)
if [ "$song" = "$short_song" ]
then
echo -n
else
song="$short_song..."
fi
artist=$(playerctl metadata artist)
short_artist=$(echo $artist | head -c $MAX_ARTIST_LEN)
if [ "$artist" = "$short_artist" ]
then
echo -n
else
artist="$short_artist..."
fi
echo$song - $artist
#echo $song