Does Kwin script's callDBus support a{sv} argument type?

Phương Lê Hoàng lehoangphuongbg at gmail.com
Wed Mar 10 12:08:02 GMT 2021


Vào Th 4, 10 thg 3, 2021 vào lúc 20:57 Nicolas Fella
<nicolas.fella at gmx.de> đã viết:
>
> Hi,
>
> a very blind guess, not really tested: Try putting quotes around count,
> i.e. { "count-visible": true, "count": 1 }
>

Too bad no difference. It's javascript so the quotes are actually
unnecessary. Appreciate your response.

> Cheers
>
> Nico
>
> On 3/10/21 12:43 PM, Phương Lê Hoàng wrote:
> > Hi all,
> >
> > I'm writing a Kwin script to automatically set an unread count badge
> > to an app's launcher icon by parsing its title.
> >
> > I'm stuck at the part where I need to call an DBus API, but always get
> > "Received D-Bus message is error". I appreciate any help to show me
> > where I got it wrong, or callDBus just doesn't support passing a{sv}
> > argument yet.
> >
> > This is the method that I need to call:
> > https://wiki.ubuntu.com/Unity/LauncherAPI#Low_level_DBus_API:_com.canonical.Unity.LauncherEntry
> > <https://wiki.ubuntu.com/Unity/LauncherAPI#Low_level_DBus_API:_com.canonical.Unity.LauncherEntry>
> >
> > I can use gdbus and it successfully update the launcher's icon badge:
> >
> > gdbus emit --session --object-path
> > /com/canonical/unity/launcherentry/1 --signal
> > com.canonical.Unity.LauncherEntry.Update
> > "application://chrome-ebcgcbpjedmohalnmiodnfidggpfcehe-Default.desktop"
> > "{'count-visible': <true>, 'count': <2>}"
> >
> > But when I attempt to use callDBus in my script, it fails:
> >
> > callDBus(
> >   "com.canonical.Unity", // Service
> >   "/com/canonical/unity/launcherentry/1", // Path
> >   "com.canonical.Unity.LauncherEntry", // Interface
> >   "Update", // Method
> > "application://chrome-ebcgcbpjedmohalnmiodnfidggpfcehe-Default.desktop",
> >   { "count-visible": true, count: 1 }
> > );
> >
> > I tried to read the source code of callDBus and failed to understand
> > whether it supports a{sv} or not, since I'm not familiar with Qt and C++.
> > https://invent.kde.org/plasma/kwin/-/blob/master/src/scripting/scripting.cpp#L253
> > <https://invent.kde.org/plasma/kwin/-/blob/master/src/scripting/scripting.cpp#L253>
> >
> > Thanks in advance for any help.
> > Regards,
> > Le Phuong



More information about the kde-devel mailing list