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, keeping non-MPRIS #500

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
17 changes: 6 additions & 11 deletions mediaplayer/mediaplayer
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,14 @@ 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 '{{default(artist, "\004\005")}} - {{title}}' 2>/dev/null);
chomp $metadata;
$metadata =~ s/^\004\005 - //;
# 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