hello! I’m trying to send a desktop notification from my kwin script using qdbus:
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'org.freedesktop.Notifications.Notify',
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
from journalctl I can see this error: qt.dbus.integration: QDBusConnection: error: could not send message to service "org.freedesktop.Notifications" path "/org/freedesktop/Notifications" interface "org.freedesktop.Notifications" member "org.freedesktop.Notifications.Notify": Invalid method name: org.freedesktop.Notifications.Notify
i tried changing org.freedesktop.Notifications.Notify to only Notify with the same effect. what am I doing wrong?
Try changing the 3rd and 4th parameters to just Notify.
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'Notify',
'Notify',
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
I get this message:
qt.dbus.integration: QDBusConnection: error: could not send message to service "org.freedesktop.Notifications" path "/org/freedesktop/Notifications" interface "Notify" member "Notify": Invalid interface class: Notify
I was unclear, sorry. Also get rid of the 4th parameter.
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'Notify',
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
gives the same error message as before, but
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'org.freedesktop.Notifications.Notify',
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
does not give any error, it just does nothing (no notification arrives). if instead I change "appname" with "appname 2" (with the space) I get this error:
qt.dbus.integration: QDBusConnection: error: could not send message to service "org.freedesktop.Notifications" path "/org/freedesktop/Notifications" interface "org.freedesktop.Notifications.Notify" member "appname 2": Invalid method name: appname 2
thank you very very much for your help!
I think what you want is
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'Notify'
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
Couldn’t make it work either, and from dbus-monitor output it’s unclear to me what the error is as the signature seems correct?
KWin script doesn’t work
callDBus(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'Notify',
'appname',
0,
"kwin",
"summary",
"body",
[],
{},
10000
);
dbus-monitor output:
method call time=1716317968.084560 sender=:1.2784 -> destination=org.kde.KWin serial=324 path=/Scripting/Script75; interface=(null); member=run
method call time=1716317968.089895 sender=:1.1436 -> destination=org.freedesktop.Notifications serial=10745 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
string "appname"
int32 0
string "kwin"
string "summary"
string "body"
array [
]
array [
]
int32 10000
method return time=1716317968.089962 sender=:1.1436 -> destination=:1.2784 serial=10746 reply_serial=324
error time=1716317968.090537 sender=:1.1689 -> destination=:1.1436 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=10745
string "No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'sisssava{sv}i')"
Python works
import dbus
bus = dbus.SessionBus()
interface = dbus.Interface(
bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications"),
"org.freedesktop.Notifications",
)
interface.Notify("appname", 0, "kwin", "summary", "body", [], {}, 10000)
dbus-monitor output:
method call time=1716318079.051155 sender=:1.3148 -> destination=:1.1689 serial=4 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
string "appname"
uint32 0
string "kwin"
string "summary"
string "body"
array [
]
array [
]
int32 10000
It’s very strange, from python it works flawlessly also for me
I found a bug about this, from about a month ago: 486024 – callDBus fails for specific number types