this post was submitted on 15 May 2025
28 points (100.0% liked)

Linux

7409 readers
263 users here now

A community for everything relating to the GNU/Linux operating system

Also check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
 

I have a virtual source and a virtual sink which I'm using to forward audio to/from chat apps (Matrix, Discord, Zoom, etc.) so I can control the mic/output volume independently of everything else on my system. I have them setup and working fine using pipewire.conf.d files. The problem is that using wpctl to change volume requires having an ID, but those aren't static. Normally the solution would be to use @DEFAULT_AUDIO_SOURCE@ (or sink), but that wouldn't work in this case. Is there a way to adjust volume/toggle mute without having the ID? Or alternatively, is there a way to get the ID for a specific node name that I can put in a bash script?

If I'm asking this in the wrong place, is there a better place to go?

top 5 comments
sorted by: hot top controversial new old
[–] domi@lemmy.secnd.me 5 points 1 week ago (1 children)

I did something similar a while ago but for changing volume on a single application, should work for devices as well though since both are just nodes.

Try this:

#!/bin/sh

node_id=$(pw-dump | jq '.[] | select(.type == "PipeWire:Interface:Node" and .info.props."node.name" == "Virtual-Sink-1") | .id')

echo "Adjusting volume for $node_id"

wpctl set-volume $node_id 10%-

Replace Virtual-Sink-1 with the name of your audio device and 10%- with the operation you want to perform.

[–] Zangoose@lemmy.world 3 points 1 week ago

This works, thanks!

[–] TrashPandacoot@lemmy.world 2 points 1 week ago

I was thinking about figuring out how to set up something similar so I can adjust discord volume separately from everything else but I haven’t got around to it yet. I think the way to go would be using wpctl status To get a list of all sources and sinks and parse out the id from there

wpctl status | grep "\. Some Discord Output" | egrep '^ │( )*[0-9]*' -o | cut -c6-55 | egrep -o '[0-9]*'

I think the above would return the ID of a node named “Some Discord Output” but I’m not at my computer to check

[–] sneezycat@sopuli.xyz 1 points 1 week ago (1 children)

If I understand correctly, you can use pgrep to get the IDs of the processes you need.

[–] Zangoose@lemmy.world 3 points 1 week ago

I don't think it's a process ID? I have 2 virtual pipewire devices (one called "chat-mic" and one called "chat-speaker"). Pipewire devices (nodes) also have ID numbers, but they are assigned when the device is initialized on startup and aren't guaranteed to be the same between reboots