]> git.draconx.ca Git - fvwmconf.git/commitdiff
Merge branch 'master' of atropos:.fvwm
authorNick Bowler <draconx@gmail.com>
Sun, 1 Jun 2008 23:42:32 +0000 (19:42 -0400)
committerNick Bowler <draconx@gmail.com>
Sun, 1 Jun 2008 23:42:32 +0000 (19:42 -0400)
Conflicts:

scripts/mpdmenu.pl

1  2 
scripts/mpdmenu.pl

diff --combined scripts/mpdmenu.pl
index 94ec8d5088ab1fdc9475b4595dbe4bfc7f34a6cf,4639211c0a62f00b946c4e254dddf2dc60e90a29..ebd4c319a3883ffe8eb9c024e5ad4ee4aebeeed1
@@@ -3,7 -3,7 +3,7 @@@
  use strict;
  
  use Getopt::Long;
 -use IO::Socket;
 +use IO::Socket::INET6;
  
  use constant {
        MPD_MJR_MIN => 0,
@@@ -46,7 -46,7 +46,7 @@@ $artist = decode_utf8($artist) if defin
  $title  = decode_utf8($title)  if defined($title);;
  
  # Connect to MPD.
 -my $sock = new IO::Socket::INET(
 +my $sock = new IO::Socket::INET6(
        PeerAddr => $host,
        PeerPort => $port,
        Proto => 'tcp'
@@@ -67,27 -67,27 +67,27 @@@ if (defined $album) 
        my $entry;
  
        $menu = "MenuMPDAlbum" unless defined $menu;
-       
        $album =~ s/"/\\"/g;
        print $sock "playlistfind album \"$album\"\n";
        while (<$sock>) {
                last if (/^OK/);
                die($_) if (/^ACK/);
-       
                if (/^(\w+): (.*)$/) {
                        if ($1 eq "file") {
                                if (keys(%$entry) > 0) {
                                        addalbumentry(\@playlist, $entry)
                                }
-       
                                $entry = {};
                        }
-       
                        $entry->{$1} = $2;
                }
        }
        addalbumentry(\@playlist, $entry) if (keys(%$entry) > 0);
-       
        die("No tracks found.\n") if (!@playlist);
        foreach (sort albumsort @playlist) {
                my ($t_file, $t_trackno, $t_artist, $t_title, $t_id) = (
                        $_->{Title},
                        $_->{Id},
                );
-       
                next if (defined $artist && !$accept{albumdir($t_file)});
-       
                $t_artist = sanitise($t_artist);
                $t_title  = sanitise($t_title);
-               
                my $cmd = sprintf "AddToMenu $menu \"%d\t%s - %s\""
                                  ." Exec mpc playid %d",
                                  $t_trackno, $t_artist, $t_title, $t_id;
-       
                cmd($cmd);
        }
  } elsif (defined $artist) {
        while (<$sock>) {
                last if (/^OK/);
                die($_) if (/^ACK/);
-       
                if (/^(\w+): (.*)$/) {
                        $file       = $2    if ($1 eq "file");
                        $albums{$2} = $file if ($1 eq "Album");
                my $key      = $_;
                my $a_album  = sanitise($key);
  
 -              open THUMB, "-|", "$FVWM/scripts/thumbnail.sh",
 +              open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh",
                                         "--small", "--music", $albums{$key};
                my $thumb = <THUMB>;
                close THUMB;
 -              die("Incompetent use of thumbnail.sh") if ($?);
 +              die("Incompetent use of thumbnail.zsh") if ($?);
  
                $thumb =~ s/\n//sg;
                $thumb = "%$thumb%" if (-f $thumb);
        while (<$sock>) {
                last if (/^OK/);
                die($_) if (/^ACK/);
-       
                if (/^(\w+): (.*)$/) {
                        if ($1 eq "file") {
                                push @titles, $entry if (keys(%$entry) > 0);
                                $entry = {};
                        }
-       
                        $entry->{$1} = $2;
                }
        }
                $t_artist = sanitise($t_artist);
                $t_title  = sanitise($t_title);
  
 -              open THUMB, "-|", "$FVWM/scripts/thumbnail.sh",
 +              open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh",
                                         "--small", "--music", $t_file;
                my $thumb = <THUMB>;
                close(THUMB);
 -              die("Incompetent use of thumbnail.sh") if ($?);
 +              die("Incompetent use of thumbnail.zsh") if ($?);
  
                $thumb =~ s/\n//sg;
                $thumb = "%$thumb%" if (-f $thumb);
                        $songid = $2 if ($1 eq "songid");
                }
        }
-       die("Failed status query\n") unless (defined $state && defined $songid);
+       die("Failed status query\n") unless (defined $state);
  
-       print $sock "playlistid $songid\n";
-       while (<$sock>) {
-               last if (/^OK/);
-               die($_) if (/^ACK/);
+       cmd("AddToMenu $menu Playing Title") if ($state eq "play");
+       cmd("AddToMenu $menu Paused Title")  if ($state eq "pause");
+       cmd("AddToMenu $menu Stopped Title") if ($state eq "stop");
  
-               if (/^(\w+): (.*)$/) {
-                       $entry{$1} = $2;
+       if (defined $songid) {
+               print $sock "playlistid $songid\n";
+               while (<$sock>) {
+                       last if (/^OK/);
+                       die($_) if (/^ACK/);
+                       if (/^(\w+): (.*)$/) {
+                               $entry{$1} = $2;
+                       }
                }
-       }
-       die("Failed data query\n") unless (keys(%entry) > 0);
+               die("Failed data query\n") unless (keys(%entry) > 0);
  
-       open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh",
-                                "--image", "--music",  $entry{file};
-       my $thumb = <THUMB>;
-       my $scan  = <THUMB>;
-       close(THUMB);
-       die("Incompetent use of thumbnail.zsh") if ($?);
 -              open THUMB, "-|", "$FVWM/scripts/thumbnail.sh",
++              open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh",
+                                        "--image", "--music",  $entry{file};
+               my $thumb = <THUMB>;
+               my $scan  = <THUMB>;
+               close(THUMB);
+               die("Incompetent use of thumbnail.sh") if ($?);
  
-       $thumb =~ s/\n//sg;
-       $scan  =~ s/\n//sg;
+               $thumb =~ s/\n//sg;
+               $scan  =~ s/\n//sg;
  
-       cmd("AddToMenu $menu Playing Title") if ($state eq "play");
-       cmd("AddToMenu $menu Paused Title")  if ($state eq "pause");
-       cmd("AddToMenu $menu Stopped Title") if ($state eq "stop");
-       if (-f $thumb) {
-               cmd("AddToMenu $menu \"*$thumb*\" "
-                       ."Exec exec gqview ".shellify($scan, 0));
+               if (-f $thumb) {
+                       cmd("AddToMenu $menu \"*$thumb*\" "
+                               ."Exec exec gqview ".shellify($scan, 0));
+               }
+               cmd("AddToMenu $menu \"Title:   ".sanitise($entry{Title})."\" "
+                       ."Popup MenuMPDTitle");
+               cmd("AddToMenu $menu \"Artist:  ".sanitise($entry{Artist})."\" "
+                       ."Popup MenuMPDArtist");
+               cmd("AddToMenu $menu \"Album:   ".sanitise($entry{Album})."\" "
+                       ."Popup MenuMPDAlbum");
+               cmd("AddToMenu $menu \"\" Nop");
+       } else {
+               cmd("AddToMenu $menu \"<Song info unavailable>\"");
+               cmd("AddToMenu $menu \"\" Nop");
        }
-       cmd("AddToMenu $menu \"Title:   ".sanitise($entry{Title})."\" "
-               ."Popup MenuMPDTitle");
-       cmd("AddToMenu $menu \"Artist:  ".sanitise($entry{Artist})."\" "
-               ."Popup MenuMPDArtist");
-       cmd("AddToMenu $menu \"Album:   ".sanitise($entry{Album})."\" "
-               ."Popup MenuMPDAlbum");
-       cmd("AddToMenu $menu \"\" Nop");
  
        if ($state eq "play" || $state eq "pause") {
                cmd("AddToMenu $menu \"\t\tNext%$icons/next.svg:16x16%\" "
                           ."--menu MenuMPDAlbum "
                           ."--album  ".shellify($entry{Album}, 1)." "
                           ."--artist ".shellify($entry{Artist}, 1)."\"");
-       
        cmd("DestroyFunc MakeMenuMPDArtist");
        cmd("AddToFunc   MakeMenuMPDArtist
             + I DestroyMenu MenuMPDArtist