Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Unable to display volume when using pipewire
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Snow-0
n00b
n00b


Joined: 02 May 2021
Posts: 23

PostPosted: Wed Jul 14, 2021 9:16 pm    Post subject: [Solved] Unable to display volume when using pipewire Reply with quote

I have a script that outputs the current volume for my headphone when using pulseaudio, which is displayed via dwmblocks. When running pipewire, the script does not work properly and does not update the status bar when increasing or decreasing the volume.

This is the command I use to display my volume when using pulseaudio:
Code:
(pactl list sinks | grep '^[[:space:]]Volume:' |     head -n $(( $SINK + 1 )) | tail -n 1 |
    sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')


Is there an alternative way to display the volume when using pipewire?


Last edited by Snow-0 on Thu Jul 15, 2021 1:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
Snow-0
n00b
n00b


Joined: 02 May 2021
Posts: 23

PostPosted: Thu Jul 15, 2021 1:42 pm    Post subject: Reply with quote

When running
Code:
pactl list sinks


It lists this

Code:

Sink #42
   State: SUSPENDED
   Name: alsa_output.pci-0000_23_00.1.hdmi-stereo
   Description: GK208 HDMI/DP Audio Controller Digital Stereo (HDMI)
   Driver: PipeWire
   Sample Specification: s32le 2ch 48000Hz
   Channel Map: front-left,front-right
   Owner Module: 4294967295
   Mute: no
   Volume: front-left: 54827 /  84% / -4.65 dB,   front-right: 54827 /  84% / -4.65 dB
           balance 0.00
   Base Volume: 65536 / 100% / 0.00 dB
   Monitor Source: alsa_output.pci-0000_23_00.1.hdmi-stereo.monitor
   Latency: 0 usec, configured 0 usec
   Flags: HARDWARE DECIBEL_VOLUME LATENCY
   Properties:
      object.path = "alsa:pcm:0:hdmi:0:playback"
      api.alsa.path = "hdmi:0"
      api.alsa.pcm.card = "0"
      api.alsa.pcm.stream = "playback"
      audio.channels = "2"
      audio.position = "FL,FR"
      device.routes = "1"
      alsa.resolution_bits = "16"
      device.api = "alsa"
      device.class = "sound"
      alsa.class = "generic"
      alsa.subclass = "generic-mix"
      alsa.name = "Generic Digital"
      alsa.id = "Generic Digital"
      alsa.subdevice = "0"
      alsa.subdevice_name = "subdevice #0"
      alsa.device = "3"
      alsa.card = "0"
      alsa.card_name = "HDA NVidia"
      alsa.long_card_name = "HDA NVidia at 0xf5080000 irq 41"
      alsa.driver_name = "snd_hda_intel"
      device.profile.name = "hdmi-stereo"
      device.profile.description = "Digital Stereo (HDMI)"
      card.profile.device = "1"
      device.id = "38"
      factory.name = "api.alsa.pcm.sink"
      priority.driver = "696"
      priority.session = "696"
      media.class = "Audio/Sink"
      node.nick = "HDA NVidia"
      node.name = "alsa_output.pci-0000_23_00.1.hdmi-stereo"
      device.description = "GK208 HDMI/DP Audio Controller Digital Stereo (HDMI)"
      device.icon_name = "audio-card-hdmi"
      node.pause-on-idle = "false"
      factory.id = "18"
      client.id = "32"
      node.driver = "true"
      factory.mode = "merge"
      audio.adapt.follower = ""
      library.name = "audioconvert/libspa-audioconvert"
      object.id = "42"
      node.max-latency = "8192/48000"
   Ports:
      hdmi-output-0: HDMI / DisplayPort (priority: 5900)
   Active Port: hdmi-output-0
   Formats:
      pcm

Sink #43
   State: RUNNING
   Name: alsa_output.usb-Kingston_HyperX_Cloud_Flight_Wireless_Headset-00.analog-stereo
   Description: HyperX Cloud Flight Wireless Headset Analog Stereo
   Driver: PipeWire
   Sample Specification: s16le 2ch 48000Hz
   Channel Map: front-left,front-right
   Owner Module: 4294967295
   Mute: no
   Volume: front-left: 47982 /  73% / -8.12 dB,   front-right: 47982 /  73% / -8.12 dB
           balance 0.00
   Base Volume: 65536 / 100% / 0.00 dB
   Monitor Source: alsa_output.usb-Kingston_HyperX_Cloud_Flight_Wireless_Headset-00.analog-stereo


My headset was sink 43, the second one in the list.

In the original post, I changed this part of the command
Code:
 head -n $(( $SINK + 1 ))


to this

Code:
 head -n $(( $SINK + 2 ))


This solved the problem.

[Moderator edit: changed [quote] tags to [code] tags to preserve output layout. -Hu]
Back to top
View user's profile Send private message
Snow-0
n00b
n00b


Joined: 02 May 2021
Posts: 23

PostPosted: Thu Jul 15, 2021 2:56 pm    Post subject: Reply with quote

When rebooting the sink number gets mixed up. I ended up using pamixer from EmilienMottet's overlay. Then I used this command to get my volume instead

Code:
 pamixer --get-volume
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum