http://qs321.pair.com?node_id=1057801

MichaelMeyer has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

How would one nowadays control the sound volume on a Linux system (using ALSA) from Perl? All that I've found is Audio::Mixer, which seems to be designed for OSS, only....

I would need to mute+unmute at least the Master channel, as well as control it's actual volume value?

Is there a Module for this?

Replies are listed 'Best First'.
Re: control Audio Volume in Linux
by kcott (Archbishop) on Oct 11, 2013 at 04:12 UTC
Re: control Audio Volume in Linux
by dasgar (Priest) on Oct 11, 2013 at 04:48 UTC

    A quick Google search found the this link with some information that might help.

Re: control Audio Volume in Linux
by stefbv (Curate) on Oct 11, 2013 at 08:14 UTC

    If you use KDE4, DBus can be used like this:

    #!/bin/env perl use strict; use warnings; use Net::DBus; #use Net::DBus::Dumper; my $bus = Net::DBus->session; my $mixer = eval { $bus->get_service('org.kde.kmix')->get_object('/Mixers/0/Master_0' +); }; if ( $@ ) { die "Error: $@.\n"; } #print dbus_dump($mixer); $mixer->toggleMute; #$mixer->decreaseVolume; #$mixer->increaseVolume;

    I suppose it can be adapted for other desktops also.

    Stefan