All pastes #433428 Raw Edit

Something

public text v1 · immutable
·published 2007-04-10 20:01 UTC
rendered paste body
#!/usr/bin/perl -w

use Audio::Mixer;

my $cntrl = "pcm"; 	
my $incr  = 5; 
my $std   = 75;

my $call = shift(@ARGV);
my @vol = &get_volume();
foreach(@vol) {
        /* increments by 5 */
	if($call eq "up") {
		$_ += $incr;
        /* decrements by 5 */
	} elsif($call eq "down") {
		$_ -= $incr;
        /* sets to whatever $std is */
	} elsif($call eq "std") {
		$_ = $std;
        /* mutes */
	} else {
		$_ = 0;
	}
}
&change_volume($vol[0], $vol[1]);

sub get_volume() {
	return Audio::Mixer::get_cval($cntrl);
}

sub change_volume($$) {
	my ($left, $right) = @_;
	
	if(Audio::Mixer::set_cval($cntrl, $left, $right)) {
		die("Couldn't set volume of ".$cntrl);
	}
}