dunst icon indicating copy to clipboard operation
dunst copied to clipboard

Subscription for some dbus properties doesn't work

Open ritze opened this issue 4 years ago • 7 comments

Subscribers to the dbus properties displayedLength, historyLength and waitingLength are not informed about changes. In contrast this works with the property paused.

Start:

$ dbus-monitor path=/org/freedesktop/Notifications
signal time=1613901346.651660 sender=org.freedesktop.DBus -> destination=:1.134 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.134"
signal time=1613901346.651714 sender=org.freedesktop.DBus -> destination=:1.134 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.134"

After sending a notification with $ notify-send test:

method call time=1613901357.736964 sender=:1.135 -> destination=:1.116 serial=6 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call time=1613901357.738638 sender=:1.135 -> destination=:1.116 serial=7 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string ""
   string "test"
   string ""
   array [
   ]
   array [
      dict entry(
         string "urgency"
         variant             byte 1
      )
   ]
   int32 -1
signal time=1613901359.306892 sender=:1.116 -> destination=:1.135 serial=26 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=NotificationClosed
   uint32 6
   uint32 2

After pause dunst with dunstctl set-paused true:

method call time=1613901403.092561 sender=:1.136 -> destination=org.freedesktop.Notifications serial=2 path=/org/freedesktop/Notifications; interface=org.freedesktop.DBus.Properties; member=Set
   string "org.dunstproject.cmd0"
   string "paused"
   variant       boolean true
signal time=1613901403.093260 sender=:1.116 -> destination=(null destination) serial=27 path=/org/freedesktop/Notifications; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.dunstproject.cmd0"
   array [
      dict entry(
         string "paused"
         variant             boolean true
      )
   ]
   array [
   ]

Installation info

  • Version: Dunst - A customizable and lightweight notification-daemon v1.5.0-93-g3994895
  • Install type: git, manual build, executed locally within the build folder
  • Distro and version: archlinux

ritze avatar Feb 21 '21 09:02 ritze

the *Length properties are not marked to emit a changed status signal, so the behaviour is correct here. I'm curious, what's the usecase to want to monitor these fields constantly?

tsipinakis avatar Feb 21 '21 10:02 tsipinakis

I'm writing a plugin for the py3status, a status bar for the i3 window tiling manager. If dunst is paused, because you want to be concentrate yourself on work, the plugin shall show the waiting notifications as a number (waitingLength).

ritze avatar Feb 21 '21 10:02 ritze

After adding the emit in dbus.c:

    "        <property name=\"displayedLength\" type=\"u\" access=\"read\">"
    "            <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>"
    "        </property>"

Nothing changed. I still don't get a dbus signal.

ritze avatar Mar 14 '21 13:03 ritze

I don't know dbus too well, but you can take a look at how it's done for the paused property. When the property is changed this function is called.

                g_dbus_connection_emit_signal(connection,
                                              NULL,
                                              object_path,
                                              "org.freedesktop.DBus.Properties",
                                              "PropertiesChanged",
                                              g_variant_new("(sa{sv}as)",
                                                            interface_name,
                                                            builder,
                                                            invalidated_builder),
                                              NULL);

fwsmit avatar Mar 14 '21 18:03 fwsmit

That's something I can work with. Thank you!

ritze avatar Mar 20 '21 13:03 ritze

After some investigation today I figured out that the dbus properties like paused or waiting notifications are never updated. I couldn't find any trigger called in dunst.c and executed in dbus.c, which will notify all subscribers.

For pause the the subscriptions only works if dunst was paused through the dbus interface and not through SIGUSR1 or SIGUSR2.

ritze avatar Dec 25 '21 13:12 ritze

Shouldn't be too hard to fix. Do you want to take a stab at it?

fwsmit avatar Dec 25 '21 17:12 fwsmit