#!/usr/bin/perl use strict; use POSIX; unless (!@ARGV || ($ARGV[0] =~ /:/)) { print "Usage: $0 [hour:min]\nThis program will start XMMS with the current playlist at high volume at a given time. If hour: min is not given, the alarm will go off almost immediately.\n"; exit; } my @wake = split /:/, $ARGV[0]; my @current; if (@ARGV) { print "Alarm is set for $wake[0]:$wake[1].\n"; do { my @timenow = localtime(time); @current = ($timenow[2], $timenow[1]); sleep 5; } while (($wake[0] != $current[0]) || ($wake[1] != $current[1])); } if (my $pid = fork) { # parent print "It's $wake[0]:$wake[1] now.\n"; my $mixpid; unless ($mixpid = fork) { exec "mixer vol 100:100"; } waitpid($mixpid, 0); waitpid($pid, 0); } else { # child exec "xmms -p"; } my $mixpid; unless ($mixpid = fork) { exec "mixer vol 75:75"; } waitpid($mixpid, 0);