2

I removed notify-osd but then another notification started appearing instead when changing the volume:

Is there a way to remove this notification as well? I use my Logitech G110 keyboard's volume controller to adjust the volume.

Radu Rădeanu
  • 169,590
Qcc
  • 21
  • 2

1 Answers1

2

The volume notification from your screenshot is generated by the media-keys plugin to gnome-settings-daemon. Unfortunately, after browsing through the code for a bit, it doesn't appear that there is a way to disable the OSD without breaking the functionality for the keys (without of course editing the code and recompiling, which is of course a viable option).

However, I did notice that it is suppressed when the Ubuntu notifications are enabled. That doesn't immediately help us of course, because you wanted to and have removed notify-osd. But I came up with a sort of silly solution. Instead, we create our own simple notification daemon which says it supports the volume messages, and then silently eats all notifications. The code:

from __future__ import print_function

import dbus
import dbus.service
import dbus.mainloop.glib

from gi.repository import GObject

SERVICE_NAME = "org.freedesktop.Notifications"
SERVICE_PATH = "/org/freedesktop/Notifications"

class Notifications(dbus.service.Object):
  @dbus.service.method(SERVICE_NAME,
      in_signature="susssasa{sv}i", out_signature="u")
  def Notify(self, app_name, id, icon, summary, body, actions, hints, timeout):
    print(app_name, summary, body)
    return 1

  @dbus.service.method(SERVICE_NAME,
      in_signature="u", out_signature="")
  def CloseNotification(self, id): 
    pass

  @dbus.service.method(SERVICE_NAME,
      in_signature="", out_signature="as")
  def GetCapabilities(self):
    return ["x-canonical-private-synchronous"]

  @dbus.service.method(SERVICE_NAME,
      in_signature="", out_signature="ssss")
  def GetServerInformation(self):
    return ("empty", "empty", "empty", "empty")

if __name__ == "__main__":
  dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

  session_bus = dbus.SessionBus()
  name = dbus.service.BusName(SERVICE_NAME)
  path = Notifications(session_bus, SERVICE_PATH)

  mainloop = GObject.MainLoop()
  mainloop.run()

You can of course comment out the print function in the Notify method, I just thought it would be nice to include some output so you could see it is working. GetCapabilities is where the magic happens, gnome-settings-daemon thinks we support it so it doesn't use its own OSD.

Jason Conti
  • 2,371
  • Copy the code above into a file such as notifications.py and then in a terminal run: python notifications.py; (also works with python3). After that test your media keys to confirm you are not getting volume notifications (or any others). You could also run: notify-send Test Message; to confirm that it is receiving the notifications. If everything seems okay you could add it to Startup Applications so it starts when you login. – Jason Conti Jul 21 '13 at 16:58
  • Thanks alot! The notification is gone and also the notify-send worked :-) – Qcc Jul 21 '13 at 17:21