This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problems with calling dbus to launch programs from a script

Tags: None
(comma "," separated)
edwardo
Registered Member
Posts
8
Karma
0
Hi,

I'm new to KWin & everything, so please point me elsewhere if this doesn't belong here ;-)

Sorry for the long post - TL;DR: Why does this code fail silently on 4.10 RC2 ?
Code: Select all
callDBus("org.kde.klauncher", "/KLauncher", "org.kde.KLauncher","exec_blind", "kshell4", "konsole");


I have been writing a kwin script to be able to cycle through windows of the same "type" (e.g. all browser windows) with a global shortcut, and launch the default application for selected type if none found. The first part went smoothly thanks to the great KWin doc on techbase, but I have stumbled on the "launching" part.

I first thought about using the LaunchApp plasma scripting extension as in this kdeexample script, but:
a) it isn't very clear how kwin and plasma scripting APIs interact. Would a kwin script be allowed to use the plasma API ? At least it is not the case in the KWin scripting console.
b) this would require X-Plasma-OptionalExtensions=LaunchApp in some .desktop, and I didn't understand how to test this directly in the interactive console (only way seems to be to repackage it each time, or maybe with plasmate ?)

So I went for the dbus method as per this commit, but I can't manage to call any service other than the KWin one, the calls just don't return (callback isn't called). If this is a bug I will open one, but I'm almost sure I'm doing something wrong...

Example which works:
Code: Select all
 callDBus("org.kde.kwin", "/KWin", "org.kde.KWin", "setCurrentDesktop", 2);

Examples which don't work
Code: Select all
callDBus("org.kde.klauncher", "/KLauncher", "org.kde.KLauncher","exec_blind", "kshell4", "konsole");
callDBus("org.kde.krunner","/App","org.kde.krunner","query","konsole");

The various tentatives of making the "launch" method work (and the whole code, with the global shortcuts for cycling through windows working) are available here.

Thanks for any help !

P.S.: Tested with KDE 4.10 RC2 (4.9.97) on both kubuntu 12.10 and fedora 18
mgraesslin
KDE Developer
Posts
572
Karma
7
OS
I just gave it a try, by using qdbusviewer: your commands are wrong. For the klauncher command I couldn't figure it out, but the KRunner one is supposed to be:

callDBus("org.kde.krunner","/App","org.kde.krunner.App","query","konsole");
edwardo
Registered Member
Posts
8
Karma
0
Thanks for the quick answer !

Yes, this one works with the added ".App", but is definitely not ideal for what I want to achieve.

For the klauncher one, i tried various alternatives but none of them work. I suspect something with the "QStringList" argument handling. Even in qdbusviewer the calls work leaving "QStringList" boxes empty, but don't work if you put something in it. Do you know how the QStringList parameter passing is handled by kwin scripting interface ? I have tried passing a javascript array, an empty string, null, but none work :-(

Alternatively, can you tell me how to have access to plasma scripting extensions in the interactive console, if possible ? Can it read the .desktop file, or is there a way to include it in the javascript code ?

Thanks!

Edward
mgraesslin
KDE Developer
Posts
572
Karma
7
OS
see https://bugs.kde.org/show_bug.cgi?id=311896

if the author of the patch does not reply by tomorrow, I'm going to push the patch myself.
edwardo
Registered Member
Posts
8
Karma
0
Great ! I don't know why the bug didn't show up on the searches I did while it's the second result for "kwin calldbus"...

Thanks !
edwardo
Registered Member
Posts
8
Karma
0
I confirm dbus calls are now working !

I've put the code on https://github.com/eddy-geek/kwinactivate and will try to package it for Get Hot New Stuff ASAP

Thanks again !


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft