diff options
Diffstat (limited to 'playingnow')
-rwxr-xr-x | playingnow | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/playingnow b/playingnow new file mode 100755 index 0000000..ea6c07e --- /dev/null +++ b/playingnow @@ -0,0 +1,32 @@ +#!/usr/bin/env perl + +sub show_player_meta { + my $player = shift; + + my ($artist, $album, $title, $url) = split /\|/, + `playerctl -p $player metadata --format '{{xesam:artist}}|{{xesam:album}}|{{xesam:title}}|{{xesam:url}}'`; + + $url = "" if $url =~ /^file:|spotify/; + + my $song = $album ? "$title - <i>$album</i>" : $title; + + my @lines; + push @lines, $artist if $artist; + push @lines, $song if $song; + push @lines, $url if $url; + + my @args = qw"-t 4000 -u low"; + push @args, shift @lines; + push @args, join("\n", @lines); + + system "notify-send", @args; +} + +sub players { + map { chomp $_; [split /\|/, $_] } `bash -c "paste -d '|' <(playerctl -l) <(playerctl -a status)"` +} + +for my $playerline (players()) { + my ($player, $status) = @$playerline; + show_player_meta($player) if ($status eq "Playing"); +} |