#!/usr/bin/perl use strict; use warnings; my $action = $ARGV[0]; open(IN,"/home/level1/.volcontroldata") or die "couldn't open data file: $!"; my %data; my $line; while($line = ) { my @lineArr = split /\s/,$line,2; $lineArr[1] =~ s/\s+$//; $data{$lineArr[0]}=$lineArr[1]; } close( IN ); my $volume =50; my $mute ='mute'; my $inc =5; $volume = $data{"Volume"}; $mute = $data{"Mute"}; $inc = $data{"Increment"}; if( $action =~ /mute/ ) { if( $mute =~ /unmute/ ) {$mute = 'mute';} else {$mute = 'unmute';} }elsif ( $action =~ /up/ ) { $volume = $volume + $inc; if($volume > 100) { $volume = 100;} }elsif ( $action =~ /down/ ) { $volume = $volume - $inc; if($volume < 0) { $volume = 0;} } my $truevol = $volume; my $mutemessage="Volume"; if( $mute =~ /^mute/) { #$truevol=0; $mutemessage="Muted"; } my $volmessage; my $i; for($i= 0; $i<$volume ; $i+=5) { $volmessage .= "█"; } for($i = 0; $i < 100-$volume; $i+=5) { $volmessage .= "▁"; } #print "volume: $mute $truevol\n"; system qw 'bash -c', "dcop knotify default notify kmix $mutemessage \'$volmessage\' \'\' \'\' 16 0"; my $append = " >/dev/null &"; if( ($action =~ /mute/) && ($mute =~ /unmute/) ) { print "unmuting"; for(my $i=0;$i<$truevol;$i+=$inc) { print "."; system qw 'bash -c', "amixer set Master $i% $append"; system qw 'bash -c', "amixer set LFE $i% $append"; sleep 0.1; } print "\n"; }elsif( ($action =~ /mute/) && ($mute =~ /^mute/) ) { print "muting"; for(my $i=$truevol;$i>0;$i-=$inc) { system qw 'bash -c', "amixer set Master $i% $append"; system qw 'bash -c', "amixer set LFE $i% $append"; sleep 0.05; } $truevol=0; print "\n"; } system qw 'bash -c', "amixer set Master $truevol% $append"; system qw 'bash -c', "amixer set LFE $truevol% $append"; #system qw 'bash -c', "dcop knotify default notify volume \'\' \'\' \'/home/level1/Org/Unmovable/Scripts/Sonar_pings2.wav\' \'\' 1 0 &"; #system qw 'bash -c', "amixer set PCM 100% $append"; open ( OUT, ">/home/level1/.volcontroldata" ) or die "couldn't access file for writing: $!"; print OUT "Volume $volume\n"; print OUT "Mute $mute\n"; print OUT "Increment $inc"; close (OUT);