6

Probably this question has already been answered somewhere, but I could not find it.

The situation: I am on Ubuntu 15.10, on a laptop.
I have a secondary bluetooth speakers system, on which I redirect some output (mainly the music).

I can control the volume with pactl with

pactl -- set-sink-volume bluez_sink.00_18_91_65_D8_6D +5%
pactl -- set-sink-volume bluez_sink.00_18_91_65_D8_6D -5%

and having associated this to some keyboard shortcuts I can increase and decrease it like if it'd be local.

This works fine but, unlike for the main output (the internal audio card), using this command does not produce a notification with the actual volume level.

So, how can I produce the notification with the changing icon and the bar for the volume, like Ubuntu does?

Should I use notify-send? With which parameters?
It should not be a "normal" notification, because it has to "stick" there when the volume changes and just adapt the bar...

dadexix86
  • 6,596
  • 2
  • 39
  • 113
  • No help anybody? :( – dadexix86 Nov 16 '15 at 12:46
  • I can write you something to create a notification bubble with one of the 4 icons (volume high/medium/low/muted) and a textual representation of the volume level. But the bar is beyond my powers. Shall I write an answer with that or is this not acceptable for you yet? – Byte Commander Nov 17 '15 at 17:51
  • Does it change by just changing the text inside without issuing another notification when you change multiple times in a row the volume? In this case yes. But if it changes by creating another notification than not, because I can do it myself :) – dadexix86 Nov 17 '15 at 19:09

1 Answers1

7

Yep, it should be special notification:

gdbus call --session --dest org.freedesktop.Notifications \
  --object-path /org/freedesktop/Notifications \
  --method org.freedesktop.Notifications.Notify \
    'gnome-settings-daemon' \
    0 \
    'notification-audio-volume-medium' \
    ' ' \
    '' \
    [] \
    "{'x-canonical-private-synchronous': <'volume'>, 'value': <24>}" \
    1
  1. Found by watching dbus-monitor:

    method call time=1447796042.858910 sender=:1.11 -> destination=:1.96 serial=216 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
       string "gnome-settings-daemon"
       uint32 0
       string "notification-audio-volume-medium"
       string " "
       string ""
       array [
       ]
       array [
          dict entry(
             string "x-canonical-private-synchronous"
             variant             string "volume"
          )
          dict entry(
             string "value"
             variant             int32 48
          )
       ]
       int32 -1
    
  2. Then write my own call using:

  3. Icons available are:

    find /usr/share/notify-osd/icons/hicolor/scalable/status/ -name "notification-audio-volume-*" -exec basename {} .svg \;

    notification-audio-volume-low
    notification-audio-volume-off
    notification-audio-volume-medium
    notification-audio-volume-muted
    notification-audio-volume-high
    
user.dz
  • 47,137
  • 13
  • 140
  • 258
  • 2
    This is just a WOW and +1 from me. I'm impressed that you came up with a working solution that fast despite the crappy quality of official documentations for all this stuff. I'm planning to maybe write my own implementation of Python `pynotify` directly on dbus just to avoid this documentation lack and for the fun of it. I'm planning to write a better indicator interface for Python as well. You seem to have a great knowledge in this topic, may I contact you if I need help and how should I best do this? – Byte Commander Nov 18 '15 at 09:14
  • 2
    That's it! This is just great! :D I managed to do my script and integrate it into the shortcuts, thank you very much! :D – dadexix86 Nov 18 '15 at 09:16
  • @ByteCommander thank you all, Actually not much but I followed dbus tag for few months in AU to learn it. As it is quiet related that, explore portions of gnome-settings-daemon & indicator-sound source code in few occasions in AU too. gnome-settings-daemon has a plugin that processes sound accelerator keys. Those icons are part of notify-osd package then it's source & doc should be helpful too. You are welcome, you may ping me in AU, SO, or UL on any related post/chat or even gmail with the same emanresu :D. – user.dz Nov 18 '15 at 10:09
  • 1
    Thanks, I will remember you when I start with the project. Currently I'm still busy with a Python wrapper around `appindicator`. After that I might start with the notification stuff. – Byte Commander Nov 18 '15 at 10:14
  • @ByteCommander , could I ask why you need new libappindicator wrapper? as there is a Gnome Introspection binding already available. or do you mean libindicator? – user.dz Nov 18 '15 at 10:19
  • 1
    Because I simply don't like the API and doc for both `appindicator` as well as `gi.repository.AppIndicator3`. I'm also adding some functionality. – Byte Commander Nov 18 '15 at 10:27