4 my ($head, $body) = @_;
7 defined $kid or return;
9 open STDOUT
, ">", "/dev/null";
10 exec "gdbus", "call", "-e",
11 "-d", "org.freedesktop.Notifications",
12 "-o", "/org/freedesktop/Notifications",
13 "-m", "org.freedesktop.Notifications.Notify", "--",
14 "DisOrder", "0", "audio-volume-high",
15 $head, $body, "[]", "{}", "5000";
22 open my $f, "-|", "disorder", @args;
25 if (wantarray) { return @r; }
26 elsif (@r == 1) { return $r[0]; }
27 else { return "??? multiple lines"; }
31 open my $log, "-|", "disorder", "log";
32 LINE
: while (<$log>) {
35 my $q = my $t = undef;
38 for (my $i = 0; $i < length $_; $i++) {
39 my $ch = substr($_, $i, 1);
41 if ($ch eq "n") { $ch = "\n"; }
44 push @f, $t; $q = $t = undef;
45 } elsif (defined $q) {
46 if ($ch eq "\\") { $e = 1; }
48 } elsif ($ch eq " ") {
49 push @f, $t if defined $t; $t = undef;
50 } elsif (!defined $t && ($ch eq '"' || $ch eq "'")) {
51 $t //= ""; $q = $ch; $j = $i;
56 defined $q and die "unmatched $q (pos $j) in: $_";
57 push @f, $t if defined $t;
60 if ($what eq "state") {
62 if ($st eq "disable_random") {
63 notify
"DisOrder state", "Random play disabled";
64 } elsif ($st eq "enable_random") {
65 notify
"DisOrder state", "Random play enabled";
66 } elsif ($st eq "disable_play") {
67 notify
"DisOrder state", "Playing disabled";
68 } elsif ($st eq "enable_play") {
69 notify
"DisOrder state", "Playing enabled";
70 } elsif ($st eq "pause") {
71 notify
"DisOrder state", "Paused";
72 } elsif ($st eq "resume") {
73 notify
"DisOrder state", "Resuming";
75 } elsif ($what eq "playing") {
78 for my $p ("artist", "album", "title")
79 { $p{$p} = cmd
"part", $track, "display", $p; }
80 if ($p{artist
} =~ /^[A-Z]$/)
81 { $p{artist
} = $p{album
}; $p{album
} = undef; }
82 elsif ($p{artist
} eq "share" && $p{album
} eq "disorder")
84 my $r = "$p{artist}: ‘$p{title}’";
85 if (defined $p{album
}) { $r .= ", from ‘$p{album}’"; }
86 notify
"Now playing", $r;