Recent changes Random page
GAMING
Technology
 
Gaming
Entertainment
Science Fiction
Biggest wikis
Hobbies
Music
See more...

Client talk:Mpc

From Music Player Daemon Community Wiki

Jump to: navigation, search
 
#!/usr/bin/perl
# 
# only for "display"
# needs TERM:READKEY
# apt-get install libterm-readkey-perl
# 
# 


use Term::ReadKey;


my $last = "";
my $sek = 1;
#my $nextsong = false; - develop

sub display_status
	{
	my ($sek, $nextsong) = @_;
	
	ReadMode 4; 
	while (not defined ($key = ReadKey(-1)))
		{
		print `clear`;
		print `mpc status`;
		#print "$nextsong";
		sleep $sek;
	       }
	print `clear`;
	ReadMode 1; 
	}


	print `clear`;

while(<STDIN>)
	{
	print `clear`;

	s/\r?\n//;


	if ((/^display$/)) { display_status (1,false); $last ="status"; next; }
	
	if ((/^n$/))
		{
		$last = "next";
		print `mpc next`;
		next;
		}
	
	if ((/^p$/))
		{
		$last = "prev";
		print `mpc prev`;
		next;
		}
		
	if ((/^find$/) or (/^f$/))
		{
		$last = "status";
		print "Enter String: ";
		$string = <STDIN>;
		$string =~ s/\r?\n//;
		@words = split(/\ /,$string);
		$cmd = "mpc playlist ";
		foreach $word (@words)
			{
			$cmd = "$cmd | grep $word ";
			}
		print `$cmd`;	
		next;
		}

		
	if ((/^quit$/) or (/^exit$/) or (/^q$/))
		{
		print `clear`;
		exit 0;
		}

	if (/^$/)
		{
		print `mpc $last`;
		next;
		}

	$last = $_;
	print `mpc $_`; 
	}


i use it - and love it- heil_eris (at) gmx (dot) net