Skip to content

Modified player-mpris-simple to slice metadata #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions polybar-scripts/player-mpris-simple/player-mpris-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

player_status=$(playerctl status 2> /dev/null)

if [ "$player_status" = "Playing" ]; then
echo "#1 $(playerctl metadata artist) - $(playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo "#2 $(playerctl metadata artist) - $(playerctl metadata title)"
#this function slice the artist length to 15 characters and 20 characters for the title preventing it from taking all the polybar space
print_metadata () {
player_title=$(playerctl metadata title 2> /dev/null)
player_artist=$(playerctl metadata artist 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
echo "#1 ${player_artist::15} - ${player_title::20}"
elif [ "$player_status" = "Paused" ]; then
echo "#2 ${player_artist::15} - ${player_title::20}"
fi
}

if [ "$player_status" = "" ]; then
echo "#3 No player found"
else
echo "#3"
print_metadata
fi