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

using dbus with konsole

Tags: konsole konsole konsole
(comma "," separated)
jomk
Registered Member
Posts
4
Karma
0
OS

using dbus with konsole

Tue Jun 30, 2009 5:15 pm
Hi, I recently changed my KDE version from 3.x to 4.2.2 (kubuntu). I am having a problem because the new KDE no longer has dcop, it now apparently uses dbus instead, which I am not knowledgeable about.

I have a script I use that opens a new session in the current konsole window, using a specified profile. Or it used to, when dcop was there. Now it doesn't work anymore. The relevant line is:

Code: Select all
/usr/bin/dcop konsole-$pid konsole newSession $profile


How can I do this using dbus?

Thanks!
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: using dbus with konsole

Tue Jun 30, 2009 8:59 pm
You can use qdbusviewer as reference and qdbus in sustitution of dcop.

If you execute

Code: Select all
qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.newSession


works but when I try to pass parameters

Code: Select all
qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.newSession "Session" $HOME


execution fails with "Invalid number of parameters" error and I don't know why because this method supports "profile" and "directory" parameters.

I really miss a lot dcop :((.

Last edited by Ignacio Serantes on Wed Jul 01, 2009 9:33 pm, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: using dbus with konsole

Wed Jul 01, 2009 6:25 am
QDbus may not be evaluating it properly....
Code: Select all
qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.newSession "Session" $(echo $HOME)
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: using dbus with konsole

Wed Jul 01, 2009 9:43 pm
bcooksley wrote:QDbus may not be evaluating it properly....
Code: Select all
qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.newSession "Session" $(echo $HOME)
Well, I'm not sure what was the difference between your code and mine but the error was the same "Invalid number of parameters" xD

Tested with KDE 4.3 Beta and RC using openSUSE official packages.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: using dbus with konsole

Thu Jul 02, 2009 5:11 am
Try this instead... it seems to be a bug with QDBus.
Code: Select all
dbus-send --session --dest=org.kde.konsole --type=method_call /Konsole org.kde.konsole.Konsole.Session string:"Session" string:"/"
jomk
Registered Member
Posts
4
Karma
0
OS

Re: using dbus with konsole

Thu Jul 02, 2009 5:54 pm
Please excuse my ignorance of dbus... but so far none of these things work for me.


Code: Select all
$ qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.newSession
Interface 'org.kde.konsole.Konsole' not available in object /Konsole at org.kde.konsole:
org.freedesktop.DBus.Error.UnknownObject (No such object path '/Konsole')
$


Code: Select all
$dbus-send --session --dest=org.kde.konsole --type=method_call /Konsole org.kde.konsole.Konsole.Session string:"Session" string:"/"
$

(returns nothing and nothing happens)

If I just run "qdbus org.kde.konsole", it gives me a list of available objects. I do not see "/Konsole", only "/konsole", not sure if that makes a difference:

Code: Select all
$ qdbus org.kde.konsole
/
/KBookmarkManager
/KBookmarkManager/konsole
/KDebug
/MainApplication
/Sessions
/Sessions/3
/Sessions/4
/Sessions/5
/Sessions/6
/Sessions/7
/konsole
/konsole/MainWindow_1
/konsole/MainWindow_1/actions
/konsole/MainWindow_1/actions/file_quit
/konsole/MainWindow_1/actions/bookmark
/konsole/MainWindow_1/actions/add_bookmark
/konsole/MainWindow_1/actions/edit_bookmarks
/konsole/MainWindow_1/actions/options_configure_notifications
/konsole/MainWindow_1/actions/options_configure_keybinding
/konsole/MainWindow_1/actions/help_contents
/konsole/MainWindow_1/actions/help_whats_this
/konsole/MainWindow_1/actions/help_report_bug
/konsole/MainWindow_1/actions/kubuntu_get_help_online
/konsole/MainWindow_1/actions/kubuntu_translate
/konsole/MainWindow_1/actions/switch_application_language
/konsole/MainWindow_1/actions/help_about_app
/konsole/MainWindow_1/actions/help_about_kde
/konsole/MainWindow_1/actions/edit_bookmarks
/konsole/MainWindow_2
$


Also, I installed qdbusviewer, and used its interface to find the service 'org.kde.konsole'. I then went through all the dozens of methods and submethods it displayed... but I cannot see 'newSession' anywhere.

Does anyone know why my system is not working right? I am using KDE 4.2.2 on the distribution Kubuntu. Is it still possible for me to get dbus to work with konsole?
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: using dbus with konsole

Thu Jul 02, 2009 6:13 pm
jomk wrote:Also, I installed qdbusviewer, and used its interface to find the service 'org.kde.konsole'. I then went through all the dozens of methods and submethods it displayed... but I cannot see 'newSession' anywhere.

Does anyone know why my system is not working right? I am using KDE 4.2.2 on the distribution Kubuntu. Is it still possible for me to get dbus to work with konsole?


Probably, this method was not available in KDE 4.2.2 but is available in KDE 4.3.
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS

Re: using dbus with konsole

Thu Jul 02, 2009 6:19 pm
bcooksley wrote:Try this instead... it seems to be a bug with QDBus.
Code: Select all
dbus-send --session --dest=org.kde.konsole --type=method_call /Konsole org.kde.konsole.Konsole.Session string:"Session" string:"/"
No errors but do nothing :) with openSUSE KDE 4.3 RC official packages.

DCOP, my kingdom by DCOP :D.

I reread your code and works with a minor change:

Code: Select all
dbus-send --session --dest=org.kde.konsole --type=method_call /Konsole org.kde.konsole.Konsole.newSession string:"Session" string:"/"
you write Session and must be newSession :).
jomk
Registered Member
Posts
4
Karma
0
OS

Re: using dbus with konsole

Thu Jul 02, 2009 7:37 pm
Hmm... well, it wouldn't be very convenient for me to switch to kde3 4.3, particularly since 4.2 is considered the stable version. So I guess I won't be able to use dbus until the next stable version of kde comes out?

In the meantime, is it possible for me to re-activate or install dcop on my current kde, so I can use the applications that depended on it? Does anyone know how to do this?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: using dbus with konsole

Fri Jul 03, 2009 4:52 am
DCOP will be started automatically for applications that can use it. Only KDE 3 made use of DCOP I believe. Unfortunately, as a Kubuntu user you do not have that available ( although you could probably try to use the packages from 2 versions ago, but apt will likely not be too happy about this )
User avatar
darkmark
Registered Member
Posts
4
Karma
0
OS

Re: using dbus with konsole

Mon Aug 10, 2009 6:32 pm
I've got most of this working, however I cannot get the /Sessions/# path working with dbus-send. Seems to work fine in qdbusviewer.. Any hints? I'm just copying and pasting the method from qdbus, so there isn't any easy typo explanation as far as I can tell. KDE 4.3.0.

Example failure:

Code: Select all
$ qdbus $KONSOLE_DBUS_SERVICE /Sessions/5
method void org.kde.konsole.Session.close()
method QByteArray org.kde.konsole.Session.codec()
method QStringList org.kde.konsole.Session.environment()
method bool org.kde.konsole.Session.flowControlEnabled()
method int org.kde.konsole.Session.foregroundProcessId()
method bool org.kde.konsole.Session.isMonitorActivity()
method bool org.kde.konsole.Session.isMonitorSilence()
method int org.kde.konsole.Session.processId()
method void org.kde.konsole.Session.sendMouseEvent(int buttons, int column, int line, int eventType)
method void org.kde.konsole.Session.sendText(QString text)
method bool org.kde.konsole.Session.setCodec(QByteArray codec)
method void org.kde.konsole.Session.setEnvironment(QStringList environment)
method void org.kde.konsole.Session.setFlowControlEnabled(bool enabled)
method void org.kde.konsole.Session.setMonitorActivity(bool)
method void org.kde.konsole.Session.setMonitorSilence(bool)
method void org.kde.konsole.Session.setMonitorSilenceSeconds(int seconds)
method void org.kde.konsole.Session.setTitle(int role, QString title)
method QString org.kde.konsole.Session.title(int role)
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()

$ dbus-send --session --dest=$KONSOLE_DBUS_SERVICE --type=method_call '/Sessions/5' --print-reply org.kde.konsole.Session.title
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'title' in interface 'org.kde.konsole.Session' at object path '/Sessions/5' (signature '')
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: using dbus with konsole

Tue Aug 11, 2009 5:02 am
You cannot get the list of contents of a DBus objects provided path by using a method call. Try calling the "Introspect" method and provide the path as an argument to that.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
darkmark
Registered Member
Posts
4
Karma
0
OS

Re: using dbus with konsole

Tue Aug 11, 2009 2:06 pm
bcooksley wrote:You cannot get the list of contents of a DBus objects provided path by using a method call. Try calling the "Introspect" method and provide the path as an argument to that.


Thanks for the reply, however, I'm not sure what you're getting at. I'm simply calling a method, listed clearly as 'method' in the returned list from 'qdbus'. qdbus is really only returning the pretty print results from the xml returned by introspectable. See my quandry?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: using dbus with konsole

Wed Aug 12, 2009 5:49 am
Oops, my mistake.

Code: Select all
method QString org.kde.konsole.Session.title(int role)


The problem is that you are missing the argument, "int role", which needs to specified in order to match the function call.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
darkmark
Registered Member
Posts
4
Karma
0
OS

Re: using dbus with konsole

Wed Aug 12, 2009 3:08 pm
bcooksley wrote:Oops, my mistake.

Code: Select all
method QString org.kde.konsole.Session.title(int role)


The problem is that you are missing the argument, "int role", which needs to specified in order to match the function call.


I had thought that too, but the error stays the same, regardless (specifying a role of '1' seems to work in qdbusviewer):

Code: Select all
$ dbus-send --session --dest=$KONSOLE_DBUS_SERVICE --type=method_call --print-reply /Sessions/5 org.kde.konsole.Session.title uint16:1
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'title' in interface 'org.kde.konsole.Session' at object path '/Sessions/5' (signature 'q')
$ dbus-send --session --dest=$KONSOLE_DBUS_SERVICE --type=method_call --print-reply /Sessions/5 org.kde.konsole.Session.title uint32:1
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'title' in interface 'org.kde.konsole.Session' at object path '/Sessions/5' (signature 'u')
$ dbus-send --session --dest=$KONSOLE_DBUS_SERVICE --type=method_call --print-reply /Sessions/5 org.kde.konsole.Session.title int16:1
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'title' in interface 'org.kde.konsole.Session' at object path '/Sessions/5' (signature 'n')
$ dbus-send --session --dest=$KONSOLE_DBUS_SERVICE --type=method_call --print-reply /Sessions/5 org.kde.konsole.Session.title int16:0
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'title' in interface 'org.kde.konsole.Session' at object path '/Sessions/5' (signature 'n')


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell