/omake/ut-party-add
#!/usr/bin/perl
use POSIX qw(:signal_h);
use strict;
my $uthome = "$ENV{HOME}/.utunes";
open PID, "$uthome/pid";
chomp(my $pid = <PID>);
close PID;
open CURRENT, "$uthome/current";
my $current = <CURRENT> + 1;
close CURRENT;
print "$current\n";
open PLAYLIST, "$uthome/playlist";
open NEWPLAYLIST, ">$uthome/playlist.new";
print NEWPLAYLIST scalar <PLAYLIST> while $current--;
close NEWPLAYLIST;
open NEWPLAYLIST, "| shuffle >>$uthome/playlist.new";
print NEWPLAYLIST while <PLAYLIST>;
print NEWPLAYLIST while <STDIN>;
close NEWPLAYLIST;
close PLAYLIST;
rename "$uthome/playlist.new", "$uthome/playlist";
if ($pid) {
kill SIGUSR1, $pid;
}