Score:0

Setting audio output level fails within tmux

uy flag

I am following this question to set my volume levels from the command line. I need to be able to set the volume from within a tmux session (actually from a node process running in tmux).

When I run amixer -D pulse sset Master 50% straight in my ssh session, it works just fine.

$ amixer -D pulse sset Master 50%
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 26214 [50%] [on]
  Front Right: Playback 26214 [50%] [on]

If I open tmux, then run the same command, it fails:

$ tmux
...
$ amixer -D pulse sset Master 50%
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

amixer: Mixer attach pulse error: Connection refused

Within node, I'm just using the child_process.spawn function which gives the same result as running from tmux, so I assume they are related.

What gives?

Score:0
uy flag

For this curious, this was because my tmux session was started from a system-wide service file, and didn't have the environment variables set up to talk to the user-level pulseaudio service.

Fixed by just prepending the following string to my amixer command:

PULSE_SERVER=unix:/run/user/1000/pulse/native

like so:

$ PULSE_SERVER=unix:/run/user/1000/pulse/native amixer -D pulse sset Master 50%

The /run/user/1000 may be different, you can determine it running

$ echo $XDG_RUNTIME_DIR

In a session logged in as user with the pulseaudio session you'd like to use.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.