File: volume.pl

package info (click to toggle)
libaudio-mixer-perl 0.7-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 152 kB
  • ctags: 51
  • sloc: ansic: 468; perl: 146; makefile: 8
file content (58 lines) | stat: -rwxr-xr-x 1,419 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl
# -d:ptkdb

#
# Volume control application.
# It's a very simple application which uses Mixer.pm to control
# the sound volume. It's written to be used inside the
# FVWM FvwmButtons panel.
#
# Copyright (c) 2001 Sergey Gribov <sergey@sergey.com>
# This is free software with ABSOLUTELY NO WARRANTY.
# You can redistribute and modify it freely, but please leave
# this message attached to this file.
#
# Subject to terms of GNU General Public License (www.gnu.org)
#
# Last update: $Date: 2001/03/20 00:20:50 $ by $Author: sergey $
# Revision: $Revision: 1.3 $

use Tk;
use Audio::Mixer;
use strict;

$| = 1;

my $debug = 0;
my $win_h = 69;
my $win_w = 62;

Audio::Mixer::set_mixer_dev("/dev/mixer");

my $ret = Audio::Mixer::init_mixer();
die("Can't open sound mixer...") if $ret;

my @vol = Audio::Mixer::get_cval('vol');
my $volume = ($vol[0] + $vol[1]) / 2;

my $main = MainWindow->new;
$main->geometry($win_w.'x'.$win_h.'+0-0');

my $sb = $main->Scale(-orient => 'vertical', -resolution => 1,
		      -from => 100, -to => 0, -sliderlength => 10,
		      -showvalue => 0, -variable => \$volume,
		      -command => sub{change_volume();}
		      );
$sb->pack(-fill => 'y', );

MainLoop;

print "Should never end up here... :)\n";

exit;

###################################################################
sub change_volume {
  print "$volume\n" if $debug;
  Audio::Mixer::set_cval('vol', $volume);
}