Skip to content
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

mediaplayer: use playerctl's formatting support #496

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 5 additions & 11 deletions mediaplayer/mediaplayer
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,13 @@ sub mpd {
sub playerctl {
buttons('playerctl');

my $artist = qx(playerctl $player_arg metadata artist 2>/dev/null);
chomp $artist;
my $metadata = qx(playerctl $player_arg metadata \\
--format '{{artist}} - {{title}}' 2>/dev/null);
chomp $metadata;
# exit status will be nonzero when playerctl cannot find your player
exit(0) if $? || $artist eq '(null)';
exit(0) if $? || $metadata eq '(null)';

push(@metadata, $artist) if $artist;

my $title = qx(playerctl $player_arg metadata title);
exit(0) if $? || $title eq '(null)';

push(@metadata, $title) if $title;

print(join(" - ", @metadata)) if @metadata;
print($metadata) if $metadata;
}

sub rhythmbox {
Expand Down