[pulseaudio-discuss] Change sound via acpid
Tanu Kaskinen
tanuk at iki.fi
Wed Dec 30 23:28:59 PST 2015
On Wed, 2015-12-30 at 12:11 -0800, John W wrote:
> On 12/22/15, Tanu Kaskinen <tanuk at iki.fi> wrote:
> >
> > It's not true that the system mode is unsupported
>
> I've seen this link referenced a few places. Maybe it's out of date or
> wrong, but definitely seems pretty clear on the point:
> http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/
>
> It mentions "You are using PA against the explicit recommendations of
> the maintainers...".
The wiki page is unnecessarily negative.
> It is good to know that PA will run as the 'pulse' user, though.
>
> >
> > > Next, I found out about the unix socket authentication options in
> > > /etc/pulse/default.pa
> > > ...
> >
> > The options aren't specific to the system mode. Without error messages,
> > I don't know why it didn't work. If there are multiple users running
> > pulseaudio, one problem would be all of them try to listen on the same
> > socket, which will inevitably fail.
>
> I only want to run the daemon once, but I want multiple users (in my
> case, the "main" user as well as root, via the acpid script) to be
> able to communicate with it to affect the audio.
>
> You mention error messages - I would love to provide better ones. Do
> you know any way to?
> Perhaps a way to see what PA is getting from its configuration files,
> what the final "effective config" is at the end of the process, etc?
Well, the error message from "pactl info" would be the first step. If
it's "connection refused", either the socket doesn't exist, or the
option you set in /etc/pulse/client.conf didn't have effect.
But anyway, I don't think loading an extra instance of module-native-
protocol-unix is the best alternative here.
> >
> > If it's sufficient to just mute one alsa sound
> > card, you could use amixer to mute the hardware directly. PulseAudio
> > will notice that and update its internal state accordingly. This is the
> > command:
> >
> > amixer -c0 set Master toggle
> >
> > "-c0" may refer to the wrong sound card, though (and it may refer to a
> > different sound card after rebooting). "-cNAME" is better, where NAME
> > is the sound card name shown in brackets in /proc/asound/cards.
> >
>
> I have tried the "-c" option, and it has ... "sort of" success (:
>
> In particular, mute works, but unmute does not.
> It seems that mute will affect the "mono" as well as stereo L/R
> channels, but unmute only affects mono. So the effect is that it stays
> muted.
I don't think the channels are relevant here. The problem is that when
you mute Master, PulseAudio notices that the current audio path got
muted, updates its own sink mute status, and that in turn causes
PulseAudio to mute also other mixer controls in the same path (likely
Speaker or Headphone). When you then unmute Master, the mute state in
PulseAudio doesn't change, because Speaker/Headphone are still muted in
alsa (this behaviour can probably be regarded as a bug in PulseAudio,
fixes welcome).
You could do multiple amixer calls to unmute all necessary controls,
but if you switch between headphones and speakers, the script gets a
bit more complicated, since you have to first figure out which path is
currently active.
If you only need to care about root getting access to your main user
(that is, you're the only human user of the laptop), I think the
easiest solution would be to use "sudo --user=john --set-home pactl
set-sink-mute SINK toggle". Replace SINK with the alsa sink name, you
can find the name with "pactl list sinks".
--
Tanu
More information about the pulseaudio-discuss
mailing list