blob: ea6c07e3840ce628264ee16a6f901e8228e35a06 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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");
}
|