Curses-Simp
view release on metacpan or search on metacpan
bin/pmix/pmix view on Meta::CPAN
for(my $dndx=$#dopt;$dndx;$dndx--){ splice(@dopt,$dndx,1) unless(exists($omap{$dopt[$dndx]}) || exists($sdvz{$dopt[$dndx]}));}@optz=@dopt if(!$valz{'mode'});
}
sub SaveValz{ # save current levels to a resource file
open(RCFL, '>', "$ENV{'HOME'}/.${name}rc"); for(sort(keys(%{$setz[0]}))){ print RCFL "$_:$setz[0]{$_}:$setz[1]{$_}\n"; } close(RCFL); }
sub LoadValz{ # load resource file into current levels
my @fldz = (); if(-e "$ENV{'HOME'}/.${name}rc"){
open(RCFL, '<', "$ENV{'HOME'}/.${name}rc"); for(<RCFL>){ @fldz = split /:/;
if($valz{'ster'}){ $setz[0]{$fldz[0]} = $fldz[1];
$setz[1]{$fldz[0]} = $fldz[2]; }
else { $setz[0]{$fldz[0]} = $setz[1]{$fldz[0]} = int(($fldz[1]+$fldz[2])/2.0); } }
close(RCFL); $valz{'mute'} = 0; $valz{'only'} = 0; SaveSetz(); } }
sub ToglMode{ $valz{'wich'} = 0; if($valz{'mode'} ^= 1){ @optz = sort(keys(%{$setz[0]})); } # toggle the full or small default option device display mode
else { @optz = @dopt ; } }
sub ToglMute{ if($valz{'mute'} ^= 1){ for(keys(%{$setz[0]})){ $bkst[0]{$_} = $setz[0]{$_}; $setz[0]{$_} = 0; # toggle muting (bkup cur lvlz 4 l8r restor8n)
$bkst[1]{$_} = $setz[1]{$_}; $setz[1]{$_} = 0; } }
else { for(keys(%{$bkst[0]})){ $setz[0]{$_} = $bkst[0]{$_};
$setz[1]{$_} = $bkst[1]{$_}; } } ChngBarz(); }
sub ToglAlll{ $valz{'alll'} ^= 1; ChngBarz(); } # lock slider across all chans
sub ToglTitl{ $valz{'titl'} ^= 1; ChngBarz(); } # display title bar
sub ToglInfo{ $valz{'info'} ^= 1; ChngBarz(); } # display info bar
sub ToglCnIn{ $valz{'cnin'} ^= 1; ChngBarz(); } # display info bar centered / rt-justified
sub ToglRecf{ $valz{'recf'} ^= 1; ChngBarz(); } # show valid input channels
sub ToglOnly{ $valz{'only'} ^= 1; for(keys(%{$setz[0]})){ # toggle muting all channels but the current one
if($_ ne $optz[$valz{'wich'}]){ if($valz{'only'}){ $bkst[0]{$_} = $setz[0]{$_}; $bkst[1]{$_} = $setz[1]{$_};
$setz[0]{$_} = $setz[1]{$_}= $valz{'alll'}= 0; }
else { $setz[0]{$_} = $bkst[0]{$_}; $setz[1]{$_} = $bkst[1]{$_}; } } } ChngBarz(); }
sub ToglSter{ $valz{'ster'} ^= 1; $valz{'ltrt'} = 0; ChngBarz(); } # Stereo
sub AlllBarz{ # synchronize all bar levels with the currently selected one
for(@optz){ $setz[0]{$_} = $setz[1]{$_} = $setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]}; } }
sub AsinReco{ # Assign the current input device to be the Recording source
if($recp{$optz[$valz{'wich'}]}){
if ($cnam eq 'mixr'){ Audio::Mixer::set_source($optz[$valz{'wich'}]); }
elsif($cnam eq 'ximp'){ `$chgr :r$optz[$valz{'wich'}]`; } ChngBarz(); } }
sub AsinChan{ my $chan = shift || return; # Assign a particular channel as the selected one
for($valz{'wich'} = 0; $valz{'wich'} < @optz; $valz{'wich'}++){ last if($optz[$valz{'wich'}] eq $chan); } }
sub ShowInfo{ # Display an Info dialog window
$simp->Mesg('type' => 'info',
" $name v$mjvr.$mnvr.$ptvr - by $auth
$name was inspired by alsamixer, aumix, mmix, && mmixer
Shout out to Keith && all the LBox.Org crew. Thanks to Beppu-san for
being a good friend. I hope you find $name useful. Please don't
hesitate to let me know if you app-ree-see-ate it or if you'd like
me to add something for you. I'd be glad to improve it given new
suggestions. Please support FSF.Org && EFF.Org. Thanks. TTFN.
-Pip
"); }
sub ShowHelp{ # uhh
$simp->Mesg('type' => 'help',
" $name v$mjvr.$mnvr.$ptvr - by $auth
Global Keys:
h - displays this Help screen
b - toggles Big mode (with all channel options)
S - toggles Stereo mode (for all channels that support it)
m - toggles Muting
o - toggles current channel as Only audible channel
a - toggles locked slider bar across All channels
t - toggles display of Title bar
I - toggles display of soundcard device Info
C - toggles Centering of soundcard device info
s - Save all current channel values to ~/.${name}rc
l - Load ~/.${name}rc into current channel values
r - set current channel to Record mode if valid input
v - jump to Volume channel
c - jump to Cd channel
p - jump to Pcm channel
Down Arrow - go to next channel
Up Arrow - go to previous channel
Left Arrow - lower channel level
RightArrow - raise channel level
0..9 - jump to (n * 11)% of channel (must shift for jump up)
Home - same as '0'
System Stuff:
?/H/F1 - Help : i - Info : x/q/Esc - eXit"); } FindChgr(); # verify valid /dev/mixer && chngr B4 mkng new scrn
$simp = tie(@text, 'Curses::Simp', '_flagaudr' => 0 ); LoadSetz();
tie(@fclr, 'Curses::Simp::FClr', $simp); #ToglSter() if($cnam eq 'almx');
tie(@bclr, 'Curses::Simp::BClr', $simp); DrawBarz();
while(!defined($keey) || ($keey !~ /^[xq]$/i && ord($keey) != 27)){ $keey = $simp->GetK($dela); LoadSetz(); $oidl = $idle;
if(defined($keey)){
if ( $keey eq ' ' ||
lc($keey) eq 'a'){ ToglAlll(); }
elsif(lc($keey) eq 'b'){ ToglMode(); }
elsif(lc($keey) eq 'm'){ ToglMute(); }
elsif(lc($keey) eq 'o'){ ToglOnly(); }
elsif(lc($keey) eq 't'){ ToglTitl(); }
elsif( $keey eq 'I'){ ToglInfo(); }
elsif( $keey eq 'C'){ ToglCnIn(); }
elsif( $keey eq 'R'){ ToglRecf(); }
elsif( $keey eq 'S'){ ToglSter(); }
elsif( $keey eq 's'){ SaveValz(); }
elsif( $keey eq 'l'){
if(lc($simp->Mesg('titl' => 'Are you SURE you want to Load?',
'pres' => 'Yes/No')) eq 'y') { LoadValz(); } }
elsif( $keey eq 'L'){ # L adds 'line' temporarily to small options
$valz{'alll'} = 0; ChngBarz();
$optz[@dopt] = 'line' unless($valz{'mode'});
AsinChan('line'); }
elsif( $keey eq 'i'){ ShowInfo(); }
elsif( $keey eq 'r'){ AsinReco(); }
elsif(lc($keey) eq 'v'){ AsinChan('vol'); }
elsif( $keey eq 'c'){ AsinChan('cd' ); }
elsif(lc($keey) eq 'p'){ AsinChan('pcm'); }
elsif( $keey =~ /^\d$/){ # handle number keys
if($setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]} > int($keey * 11)){
$setz[ $valz{'ltrt'}]{$optz[$valz{'wich'}]} = int($keey * 11); ChngBarz(); }
} elsif( $keey =~ /^[!@#\$%^&*()]$/){ # handle shifted number keys
$setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]} = int($slut{$keey} * 11); ChngBarz();
} elsif($keey eq 'KEY_LEFT' ){
$setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]}-- if $setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]}; ChngBarz();
} elsif($keey eq 'KEY_RIGHT'){
$setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]}++ if $setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]} < 99; ChngBarz();
} elsif($keey eq 'KEY_HOME' ){
$setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]} = 0; ChngBarz();
} elsif($keey eq 'KEY_END' ){ # END is dangerous to ears && speakers
my $sure = $simp->Mesg('titl' => '!*WARNING*! END can be loud! Are you SURE?', 'pres' => 'Yes/No');
if($sure =~ /y/i){ $setz[$valz{'ltrt'}]{$optz[$valz{'wich'}]} = 99; ChngBarz(); }
( run in 1.562 second using v1.01-cache-2.11-cpan-39bf76dae61 )