X-Git-Url: http://git.draconx.ca/gitweb/fvwmconf.git/blobdiff_plain/e63947b275af6479d3027c8cf3631d9505c27b83..9e3e0b6e4941da4fd9329dc0d1567bbbbbf58988:/scripts/mpdmenu.pl diff --git a/scripts/mpdmenu.pl b/scripts/mpdmenu.pl index 4ef7ece..c36fad7 100755 --- a/scripts/mpdmenu.pl +++ b/scripts/mpdmenu.pl @@ -1,4 +1,13 @@ #!/usr/bin/perl +# +# Copyright © 2018,2010,2012,2019 Nick Bowler +# +# Silly little script to generate an FVWM menu with various bits of MPD +# status information and controls. +# +# License WTFPL2: Do What The Fuck You Want To Public License, version 2. +# This is free software: you are free to do what the fuck you want to. +# There is NO WARRANTY, to the extent permitted by law. use strict; @@ -12,7 +21,8 @@ use constant { }; use utf8; -use encoding 'utf8'; +use open qw(:std :utf8); +binmode(STDOUT, ":utf8"); use Encode; sub cmd @@ -49,7 +59,8 @@ $title = decode_utf8($title) if defined($title);; my $sock = new IO::Socket::INET6( PeerAddr => $host, PeerPort => $port, - Proto => 'tcp' + Proto => 'tcp', + Timeout => 2 ) or die("could not open socket: $!.\n"); binmode($sock, ":utf8"); @@ -104,7 +115,8 @@ if (defined $album) { $t_title = sanitise($t_title, 0); my $cmd = sprintf "AddToMenu $menu \"%d\t%s - %s\"" - ." Exec mpc playid %d", + ." Exec exec $FVWM/scripts/mpdexec.pl" + ." playid %d", $t_trackno, $t_artist, $t_title, $t_id; cmd($cmd); @@ -200,6 +212,9 @@ if (defined $album) { s/\s+(instrumental|off vocal|short|tv)([\s-]+(mix|size|version))?$//i; s/\s+without\s+\w+$//i; + # Deal with separate movements in classical pieces. + s/: [IVX]+\..*//; + my $basetitle = $_; my $_basetitle = $basetitle; @@ -245,7 +260,9 @@ if (defined $album) { $thumb =~ s/\n//sg; $thumb = "%$thumb%" if (-f $thumb); - cmd("AddToMenu $menu \"$thumb$t_artist - $t_title\" Exec mpc playid $t_id"); + cmd("AddToMenu $menu \"$thumb$t_artist - $t_title\"" + ." Exec exec $FVWM/scripts/mpdexec.pl" + ." playid $t_id"); } } # end use locale workaround } else { @@ -311,25 +328,25 @@ if (defined $album) { if ($state eq "play" || $state eq "pause") { cmd("AddToMenu $menu \"\t\tNext%$icons/next.svg:16x16%\" " - ."Exec exec mpc next"); + ."Exec exec $FVWM/scripts/mpdexec.pl next"); cmd("AddToMenu $menu \"\t\tPause%$icons/pause.svg:16x16%\" " - ."Exec exec mpc pause") if ($state eq "play"); + ."Exec exec $FVWM/scripts/mpdexec.pl pause"); cmd("AddToMenu $menu \"\t\tPlay%$icons/play.svg:16x16%\" " - ."Exec exec mpc play") if ($state eq "pause"); + ."Exec exec $FVWM/scripts/mpdexec.pl play"); cmd("AddToMenu $menu \"\t\tStop%$icons/stop.svg:16x16%\" " - ."Exec exec mpc stop"); + ."Exec exec $FVWM/scripts/mpdexec.pl stop"); cmd("AddToMenu $menu \"\t\tPrev%$icons/prev.svg:16x16%\" " - ."Exec exec mpc prev"); + ."Exec exec $FVWM/scripts/mpdexec.pl previous"); } elsif ($state eq "stop") { cmd("AddToMenu $menu \"\t\tPlay%$icons/play.svg:16x16%\" " - ."Exec exec mpc play"); + ."Exec exec $FVWM/scripts/mpdexec.pl play"); } else { die("Unknown MPD state!\n"); } cmd("AddToMenu $menu \"\" Nop"); cmd("AddToMenu $menu \"\t\tShuffle%$icons/shuffle.svg:16x16%\" " - ."Exec exec mpc shuffle"); + ."Exec exec $FVWM/scripts/mpdexec.pl shuffle"); cmd("DestroyMenu MenuMPDTitle"); cmd("AddToMenu MenuMPDTitle DynamicPopUpAction MakeMenuMPDTitle");