Skip to content

Hide audio sinks according to PipeWire settings #16

@PhrozenByte

Description

@PhrozenByte

First of all: Thank you for your work and your great little extension here! ❤️

I'd like to suggest that the extension additionally honors PipeWire settings. PipeWire allows for complex rules to match sinks, not just based on the sink's name. Check out https://wiki.archlinux.org/title/WirePlumber#Obtain_interface_name_for_rules_matching for details.

For example, I work on my laptop in different offices. In one office the primary audio sink is the HDMI output, in another office the HDMI output isn't in use. With PipeWire it's easy to distinguish both offices by matching against the node.nick (in case of HDMI often the screen model); however, the extension only allows for name matching. It would be great if the extension could check whether a device was disabled with PipeWire and hide it in the GNOME settings as well (the audio sink can't be selected anyway). Same could be done to hide digital audio profiles.

Here are my WirePlumber ALSA rules to prioritize HDMI output with the ASUS MX279 screen and force analog audio, but disable HDMI output with the MSI Optix MAG274QRF-QD screen:

monitor.alsa.rules = [
  # ASUS MX279 screen: Prioritize device and force analog audio
  {
    matches = [
      {{
        node.name = "alsa_output.pci-0000_00_1f.3.hdmi-stereo"
        node.nick = "MX279"
      }}
    ]
    actions = {
      update-props = {
        priority.driver = 100
        priority.session = 100
        device.profile-set = "analog-only.conf"
      }
    }
  }

  # MSI Optix MAG274QRF-QD screen: Disable HDMI audio output
  {
    matches = [
      {{
        node.name = "alsa_output.pci-0000_00_1f.3.hdmi-stereo"
        node.nick = "MAG274QRF-QD"
      }}
    ]
    actions = {
      update-props = {
         node.disabled = true
      }
    }
  }
}

Here's the output of wpctl status from within the office with the ASUS MX279 screen:

$ wpctl status
PipeWire 'pipewire-0' [1.4.1, daniel@notebook, cookie:123456789]
 └─ Clients:
        [… snip …]

Audio
 ├─ Devices:
 │      35. KT USB Audio                        [alsa]
 │      81. Internes Audio                      [alsa]
 │  
 ├─ Sinks:
 │      56. KT USB Audio Analoges Stereo        [vol: 1.00]
 │  *   61. Internes Audio Digitales Stereo (HDMI) [vol: 0.64]
 │  
 ├─ Sources:
 │      66. Internes Audio Analoges Stereo      [vol: 1.00 MUTED]
 │  *   77. KT USB Audio Mono                   [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:
        [… snip …]

Video
  [… snip …]

Settings
 └─ Default Configured Devices:
         0. Audio/Sink    alsa_output.pci-0000_00_1f.3.hdmi-stereo
         1. Audio/Source  alsa_input.usb-KTMicro_KT_USB_Audio_2021-06-07-0000-0000-0000--00.mono-fallback

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions