Pat Gunn (dachte) wrote,
Pat Gunn
dachte

Look at these hands..

Look at these hands..What can be built with them?No doubt many things that will not,but they won't sit idle.

Here's a shrine to Insomnia.I don't think I'll ever forget that place...

I also just merged two of my media player wrappers into a single script..I was getting irritated because I'd modify one to add a feature, and thentry to use it in the other.. they did much of the same thing, and one wasforked from the other.. so let them merge. For your geekness enjoyment,here ya go. Oh, and if you don't know how to use this, it's probably notsomething that'd be useful to you anyhow.I call the program smartdeep, by the way.


  1. !/usr/bin/perl -w

    wrapper for media players.
sub recurse_deeplist($$;);

our %player = ( 'mp3' => 'mpg123', 'mp2' => 'mpg123', 'ogg' => 'ogg123', 'au' => 'killall esd;play', # killall makes sure esd 'wav' => 'killall esd;play', # has released snd device 'raw' => 'playraw'

  1. 'mid' => 'timidity'
);


    Specify your fullscreen movie player here.
our %movplayer =(

'rm' => 'fmplayer', 'mpeg' => 'fmplayer', 'mov' => 'fmplayer' );


    Note: for me, fmplayer is a shell script:
    #!/bin/sh
    mplayer -rootwin -fs $*


    And your partscreen movie player here.
our %wmovplayer =(

'rm' => 'mplayer', 'mpeg' => 'mplayer', 'mov' => 'mplayer' );main();

sub main{my($prefs,@flist) = handle_args(@ARGV);@flist = get_deeplist($prefs,@flist);
  1. print join("\n", @flist);
while(@flist > 0) { my $rindex = 0; if($$prefs{shuf}) {$rindex = int(rand(scalar(@flist)));} my $selected_file = $flistLINK; if($$prefs{mode} eq 'once') { print "Cut the cow at $rindex: LINK\n"; splice(@flist, $rindex, 1); }
  1. print "Moo\n";
play_file($prefs, $selected_file); sleep(1); # Some players don't let go of the sound device quick enough. # In practice, sometomes even this hasn't been enough. Is it # esd's fault? }}

sub handle_args(@;){my (@args) = @_;my %returner;my @flist;$returner{mode} = 'once';$returner{shuf} = 0;$returner{class} = 'songs';foreach my $arg (@args) { if($arg =~ /^-z$/) { $returner{mode} = 'once'; $returner{shuf} = 1; next; } if($arg =~ /^-Z$/) { $returner{mode} = 'loop'; $returner{shuf} = 1; next; } if($arg =~ /^-m$/) # fullscreen movie playing. {$returner{class} = 'movies';next;} if($arg =~ /^-M$/) # partscreen movie playing. {$returner{class} = 'Movies';next;} if($arg =~ /^-s$/) {$returner{class} = 'songs';next;} if($arg =~ /^--?h(:?elp)?$/i) {die "Usage: $0 -Z-M\n";} if((-d $arg) || (-f $arg)) {push(@flist, $arg);next;} warn "Unrecognized option LINK\n"; }if(scalar(@flist) == 0) { push(@flist, '.'); # no files = play deep hierarchy $returner{shuf} = 1; # Also, in this case, we probably want random. }return (\%returner, @flist);}

sub get_deeplist($@;){my($prefs,@flist) = @_;my @dl;foreach my $fle (@flist) { if(-d $fle) { push(@dl, recurse_deeplist($$prefs{class}, $fle)); } else { push(@dl, $fle); } }return @dl;}

sub recurse_deeplist($$;){my ($class, $path) = @_;my @interesting;opendir(HERE, $path);my @seen = grep !/^\./, # We don't want dotfiles, especially '.' and '..' readdir(HERE);closedir(HERE);foreach my $fn (@seen) { if(-d "$path/$fn") { push(@interesting,recurse_deeplist($class, "$path/$fn")); } else { my $t_ext = get_extension("$path/$fn"); if( (($class eq 'songs') && defined($player{$t_ext})) || (($class =~ /movies/i) && defined($movplayer{$t_ext})) ) { push(@interesting, "$path/$fn"); } else {

  1. print "Ignore file $path/$fn -- no player for ext LINK\n";
} } }return @interesting;}

sub get_extension($;){my ($tf) = @_;local $_;$tf =~ /.*\/.*\.(.*)$/;if(! defined($1)) {return '';}else {return lc($1);}}

sub play_file($$;){my ($prefs, $file) = @_;my $mplayer;if($$prefs{class} eq 'songs') {$mplayer = $player{get_extension($file)}; }elsif($$prefs{class} =~ 'movies') { $mplayer = $movplayer{get_extension($file)}; }elsif($$prefs{class} eq 'Movies') { $mplayer = $wmovplayer{get_extension($file)}; }

print "Play $file with " . $mplayer . "\n";system("$mplayer $file");}


Does this remind you of a particular famous painting?This picture actually gives us more information on the painting.. it's not acreation, no, this time we can understand it as a peace treaty. There's evena mediator.

Tags: tech
Subscribe

  • Substitute Gift

    This is the time where the more materialist of us are giving gifts and the geeky of us are giving GIFs. Instead, I offer you a year's end music mix:…

  • Clean Ears

    Weird Al recently released another another album, Alpocalypse. I've always liked his Polka medleys, but not having a TV means I don't hear much of…

  • Bohemian ID Card

    Anyone who has played Portal 2 and has a good knowledge of classical music, I have a question (might be spoily for those who have not yet played…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments