Bug 283719

Summary: RFE - Add ability to send commands to Konsole via D-BUS
Product: [Applications] konsole Reporter: Oleg Atamanenko <oleg.atamanenko+kde>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: adaptee, atkin901
Priority: NOR    
Version: 2.7.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.9.0
Sentry Crash Report:

Description Oleg Atamanenko 2011-10-10 16:44:35 UTC
Version:           2.7.5 (using KDE 4.7.1) 
OS:                Linux

Current DBUS API doesn't have separate method to run command in Konsole. 

And method sendText doesn't allow to send \n in command. It adds escape to \ and the result text contains \n.

As I know there is similar command exists in yakuake (https://gitorious.org/yakuake/yakuake/blobs/master/app/sessionstack.h#line85)

Could you please port this command from yakuake to konsole?

Thank you!

Reproducible: Didn't try

Steps to Reproduce:
--


Expected Results:  
--
Comment 1 Mark Atkinson 2011-10-31 16:45:36 UTC
You can send a command and have it execute, but it needs to use the correct character from your terminfo, not \n or \r\n.   Most likely this is '^M' in your case, so the following shell function will send a command to a session

sendtab () {
    sessionno=$1
    cmd=$2
    session="/Sessions/${sessionno}"
    dbus-send --session --dest=${KONSOLE_DBUS_SERVICE} --type=method_call \
    --print-reply ${session} org.kde.konsole.Session.sendText string:"$cmd^M"
}

* Note that you must use the actual control character (0x0d) and not just the string '^M' in your script (i.e.  ctrl-v+<enter key> in vim/gvim)
Comment 2 Jekyll Wu 2012-03-24 19:18:27 UTC
Git commit ba204b106577aa0e1c5662272d68b17a9e35cc9b by Jekyll Wu.
Committed on 24/03/2012 at 14:30.
Pushed by jekyllwu into branch 'master'.

Add dbus method runCommand(QString) for running command

Although the existing dbus method sendText(QString) can be used to do
the same job, it is not very friendly since users have to deal with the
problem of how to represent and send the final newline.
REVIEW: 104398
FIXED-IN: 4.9.0

M  +5    -0    src/Session.cpp
M  +5    -0    src/Session.h

http://commits.kde.org/konsole/ba204b106577aa0e1c5662272d68b17a9e35cc9b