9

I am using ArchLinux with i3. I recently switched from PulseAudio to Pipewire, since I want to switch also to Wayland and Sway in the near future.

For now, Pipewire works perfectly. Nevertheless, I have a little problem.

I am using audio devices with the same Description, so I cannot distinguish them in Pavucontrol for example. Using Pulse, I wrote an update-sink-proplist statement into my local default.pa file.

Does someone know, how to do this with Pipewire, i.e. how can I change the description of a device, if this device is connected.

Currently, I am using the default configuration of Pipewire.

My approaches:

  • I guess this probably works with pw-metadata, but I did not find the right command.

  • I added the following in ~/.config/pipewire/media-session.d/alsa-monitor.conf

{
    matches = [
        {
            node.name = "~^alsa_output.pci-0000_00_1f.3.output_analog-stereo$"
        }

    ]
    actions = {
        update-props = {
             device.description = "Laptop"
        }
    }
}

This changed the corresponding entry in the list of properties in the output of pactl list sinks, but not the actual description. Indeed, the output is

Sink #45
    ...
    Name: alsa_output.pci-0000_00_1f.3.output_analog-stereo
    Description: Built-in Audio Analog Stereo Output
    ...
    Properties:
        ...
        device.description = "Laptop"
        ...

Thanks for your help.

4 Answers 4

7

If you're following the current recommendation, using WirePlumber instead of PipeWire Media Session, the way to change a node's description (or any other property) is to create a Lua script and add it into ~/.config/wireplumber under the proper path and name.

For instance, to change the description of an ALSA node as felix wants, you would create a file such as ~/.config/wireplumber/main.lua.d/51-alsa-rename.lua with the following content:

rule = {
  matches = {
    {
      { "node.name", "equals", "alsa_output.pci-0000_00_1f.3.output_analog-stereo" },
    },
  },
  apply_properties = {
    ["node.description"] = "Laptop",
  },
}

table.insert(alsa_monitor.rules,rule)

If instead you wish to change something on a Bluetooth node or device, you could create ~/.config/wireplumber/bluetooth.lua.d/51-rename.lua with a content such as:

rule = {
  matches = {
    {
      { "node.name", "equals", "bluez_output.02_11_45_A0_B3_27.a2dp-sink" },
    },
  },
  apply_properties = {
    ["node.nick"] = "Headphones",
  },
}

table.insert(bluez_monitor.rules,rule)

The Lua scripts' filenames and locations are thus devised in a way that allows WirePlumber's Multi-path merging to run them just after the default config files (e.g. /usr/share/wireplumber/main.lua.d/50-alsa-config.lua) but before the file that loads and enables the devices (e.g. /usr/share/wireplumber/main.lua.d/90-enable-all.lua).

The properties that you can change as well as the matching rules to select devices or nodes are documented at ALSA configuration and Bluetooth configuration.

7

dllud's answer regarding WirePlumber is on the right track, but in case anyone comes across this after 2023, Lua is out and SPA-JSON is the new hotness.

mkdir -p ~/.config/wireplumber/wireplumber.conf.d
touch ~/.config/wireplumber/wireplumber.conf.d/99-renames.conf

The exact filename is not important.

The format looks like this:

monitor.alsa.rules = [
    {
        matches = [
            { node.name = "alsa_output.usb-Turtle_Beach_Elo_7.1_Air_8502FFFF8102-01.analog-stereo" }
        ],
        actions = {
            update-props = {
                node.description   = "Headset",
                device.form-factor = "headset",
                device.icon-name   = "audio-headset-symbolic",
            }
        }
    }
]

Restart wireplumber with

systemctl --user restart wireplumber.service

You can grab properties to match and change with wpctl status and wpctl inspect ##, where ## is the ID number listed by wpctl status.

On my system (openSUSE Tumbleweed), examples are found in /usr/share/doc/wireplumber/examples/wireplumber.conf.d. The alsa.conf file in particular is what I used for the above.

More documentation can be found here: https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/alsa.html

Fingers crossed that it stays stable for more than two years.

1

In addition to your own answer (node.description is the property to be updated), the configuration you stated needs to be embedded in a rules = [...] block in ~/.config/pipewire/media-session.d/alsa-monitor.conf:

rules = [
  {
    matches = [
      {
        node.name = "~^alsa_output.pci-0000_0d_00.4.analog-stereo$"
      }
    ]
    actions = {
      update-props = {
        node.description = "Headphones"
      }
    }
  }
]

Further hints in PipeWire's Wiki.

2
  • 2
    Newbie here: how do I make that description actually appear in Settings > Sound > Output > Output Device? Commented Apr 15, 2022 at 15:24
  • 2
    Same question. I added the file (I had to create directories pipewire/media-session.d and the alsa-monitor.conf file in ~/.config, since they were not there. I don't see any changes. Commented Jul 18, 2022 at 17:07
0

Nevermind, I got the answer.

In my second try, it has to be node.description instead of device.description.

1
  • Please mark the question as answered. You can even answer your own questions. Commented Sep 13, 2021 at 4:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.