#1012186 dbus: does not recognize volume media keys as MPRIS events

Package:
gnome-shell
Source:
gnome-shell
Description:
graphical shell for the GNOME desktop
Submitter:
Claudio
Date:
2022-06-05 14:00:03 UTC
Severity:
normal
Tags:
#1012186#5
Date:
2022-05-31 18:02:39 UTC
From:
To:
Dear Maintainer,

My system does not react to Volume Up/Down/Mute events, but still reacts to Play/Pause/Previous/Next.

Trying to trace the event I checked GNOME keybindings; the UI recognizes the Audio Raise/Lower/Mute Volume inputs when binding the keys, but nothing happens when I try to use them; xev does not recognize any XF86Audio* events (volume or play/pause/etc.).

From dbus-monitor I noticed that Play/Pause/Previous/Next events are recorded as (this is "Pause"):

signal time=1654019599.276609 sender=:1.37 -> destination=:1.63 serial=7245 path=/org/gnome/Shell; interface=org.gnome.Shell; member=AcceleratorActivated
   uint32 134
   array [
      dict entry(
         string "timestamp"
         variant             uint32 179801356
      )
      dict entry(
         string "action-mode"
         variant             uint32 1
      )
      dict entry(
         string "device-node"
         variant             string "/dev/input/event4"
      )
   ]
method call time=1654019599.276955 sender=:1.63 -> destination=:1.202 serial=366 path=/org/mpris/MediaPlayer2; interface=org.mpris.MediaPlayer2.Player; member=PlayPause
method return time=1654019599.277245 sender=:1.202 -> destination=:1.63 serial=396 reply_serial=366
signal time=1654019599.304921 sender=:1.202 -> destination=(null destination) serial=397 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.mpris.MediaPlayer2.Player"
   array [
      dict entry(
         string "PlaybackStatus"
         variant             string "Paused"
      )
   ]
   array [
   ]


but Volume manipulation inputs do not generate MPRIS events (uint 186 is raise volume, 183 is lower volume. Neither is followed by the corresponding MPRIS message):

signal time=1654019648.231914 sender=:1.37 -> destination=:1.63 serial=7251 path=/org/gnome/Shell; interface=org.gnome.Shell; member=AcceleratorActivated
   uint32 186
   array [
      dict entry(
         string "timestamp"
         variant             uint32 179850312
      )
      dict entry(
         string "action-mode"
         variant             uint32 1
      )
      dict entry(
         string "device-node"
         variant             string "/dev/input/event4"
      )
   ]
signal time=1654019648.583477 sender=:1.37 -> destination=:1.63 serial=7252 path=/org/gnome/Shell; interface=org.gnome.Shell; member=AcceleratorActivated
   uint32 183
   array [
      dict entry(
         string "timestamp"
         variant             uint32 179850664
      )
      dict entry(
         string "action-mode"
         variant             uint32 1
      )
      dict entry(
         string "device-node"
         variant             string "/dev/input/event4"
      )
   ]

Changing volume via `playerctl volume` works; I wrote a script to leverage it and change volume via GNOME keybindings, but that didn't work either (same issue: running the script manually works, but trying to get the media keys to call the script doesn't).

I tried two different keyboards, with the same outcome.

Hope this can be fixed (and that it's actually dbus doing this - sorry if I misfiled!).

Thanks!

#1012186#10
Date:
2022-05-31 19:51:28 UTC
From:
To:
Control: reassign -1 gnome-shell
Control: tags -1 + moreinfo

dbus is not responsible for generating events or reacting to events,
only delivering messages generated by something else, so this is very
unlikely to be a dbus bug. You implied that your UI is gnome-shell,
so I'm sending the bug report there for now, but I think it might be
working as designed.

I believe the way volume keys are meant to work in GNOME is that
gnome-shell receives the keyboard events and uses them to control the
overall volume in PulseAudio (or Pipewire if you have pipewire-pulse
installed).

The reason MPRIS is necessary is that for events like play/pause, there
is no reasonable thing that gnome-shell can do on its own: the only thing
it can usefully do is pass the event on to your active media player,
and hope it can do something useful in response. That isn't the case for
volume control, which gnome-shell can deal with in an app-independent way:
regardless of whether you are playing music through a MPRIS media player,
playing sounds from a non-MPRIS source like a game, both, or neither,
the Shell changes the volume level directly, which will result in media
players, games, system sounds and all other sound sources getting louder
or quieter as appropriate.

So I think this is probably working as designed, unless the volume is
not actually changing (in which case that would be a problem with the
interaction between gnome-shell and pulseaudio).

If you're using gnome-shell in its default Wayland mode, any key that is
grabbed by gnome-shell is not going to be visible to the X11 emulation
provided by Xwayland, and therefore not visible to xev. That's working
as designed. For applications, the result of pressing volume up/down keys
should be indistinguishable from the result of dragging the GUI volume
slider: either way, the representation is "volume changed".

    smcv

#1012186#21
Date:
2022-06-05 13:57:12 UTC
From:
To:
Thank you Simon,

turns out you hit the nail on the head: I had pulseaudio and pipewire, but
did not have pipewire-pulse installed.

Installed that, rebooted, and it's now working: volume up and down out of
the box, mute when I set the keybindings.

@gnome-shell team: considering I am on what is basically a fresh install,
should pipewire-pulse come preinstalled? My system, out of the box (from a
netinstall), comes with these packages (except pipewire-pulse, which I just
installed, and probably vlc-plugin-pipewire, which may have been installed
along with VLC)

$ dpkg -l | grep -E "pulseaudio|pipewire"
ii  gstreamer1.0-pipewire:amd64           0.3.51-1
  amd64        GStreamer 1.0 plugin for the PipeWire multimedia server
ii  gstreamer1.0-pulseaudio:amd64         1.20.2-1
  amd64        GStreamer plugin for PulseAudio (transitional package)
ii  libpipewire-0.3-0:amd64               0.3.51-1
  amd64        libraries for the PipeWire multimedia server
ii  libpipewire-0.3-common                0.3.51-1
  all          libraries for the PipeWire multimedia server - common files
ii  libpipewire-0.3-modules:amd64         0.3.51-1
  amd64        libraries for the PipeWire multimedia server - modules
ii  pipewire:amd64                        0.3.51-1
  amd64        audio and video processing engine multimedia server
ii  pipewire-bin                          0.3.51-1
  amd64        PipeWire multimedia server - programs
ii  pipewire-media-session                0.4.1-2
 amd64        example session manager for PipeWire
ii  pipewire-pulse                        0.3.51-1
  amd64        PipeWire PulseAudio daemon
ii  pulseaudio                            15.0+dfsg1-4
  amd64        PulseAudio sound server
ii  pulseaudio-module-bluetooth           15.0+dfsg1-4
  amd64        Bluetooth module for PulseAudio sound server
ii  pulseaudio-utils                      15.0+dfsg1-4
  amd64        Command line tools for the PulseAudio sound server
ii  vlc-plugin-pipewire:amd64             3-1
 amd64        PipeWire audio plugins for VLC

Thanks!