1#!/usr/local/bin/perl
2# -d:ptkdb
3
4#
5# Volume control application.
6# It's a very simple application which uses Mixer.pm to control
7# the sound volume. It's written to be used inside the
8# FVWM FvwmButtons panel.
9#
10# Copyright (c) 2001 Sergey Gribov <sergey@sergey.com>
11# This is free software with ABSOLUTELY NO WARRANTY.
12# You can redistribute and modify it freely, but please leave
13# this message attached to this file.
14#
15# Subject to terms of GNU General Public License (www.gnu.org)
16#
17# Last update: $Date: 2001/03/20 00:20:50 $ by $Author: sergey $
18# Revision: $Revision: 1.3 $
19
20use Tk;
21use Audio::Mixer;
22use strict;
23
24$| = 1;
25
26my $debug = 0;
27my $win_h = 69;
28my $win_w = 62;
29
30Audio::Mixer::set_mixer_dev("/dev/mixer");
31
32my $ret = Audio::Mixer::init_mixer();
33die("Can't open sound mixer...") if $ret;
34
35my @vol = Audio::Mixer::get_cval('vol');
36my $volume = ($vol[0] + $vol[1]) / 2;
37
38my $main = MainWindow->new;
39$main->geometry($win_w.'x'.$win_h.'+0-0');
40
41my $sb = $main->Scale(-orient => 'vertical', -resolution => 1,
42		      -from => 100, -to => 0, -sliderlength => 10,
43		      -showvalue => 0, -variable => \$volume,
44		      -command => sub{change_volume();}
45		      );
46$sb->pack(-fill => 'y', );
47
48MainLoop;
49
50print "Should never end up here... :)\n";
51
52exit;
53
54###################################################################
55sub change_volume {
56  print "$volume\n" if $debug;
57  Audio::Mixer::set_cval('vol', $volume);
58}
59