Friday, January 4, 2013

Open Konsole and execute command in it using D-Bus

Open Konsole:
qdbus org.kde.konsole /Konsole newSession
The same using `dbus-send`:
dbus-send --type=method_call --dest=org.kde.konsole /Konsole org.kde.konsole.Window.newSession  
 Open a Konsole session and execute `ls` command in it using Python:
import dbus

bus = dbus.SessionBus()

konsole = bus.get_object(
    'org.kde.konsole',  # Connection name
    '/Konsole'  # Object path

session_id = dbus.Interface(konsole, 'org.kde.konsole.Window').newSession()

session = bus.get_object('org.kde.konsole', '/Sessions/%s' % session_id)

No comments:

Post a Comment