Bug 126702 - Need "execute command in new tab" command-line option and DCOP interface
Summary: Need "execute command in new tab" command-line option and DCOP interface
Status: RESOLVED WORKSFORME
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-04 05:51 UTC by Tristan Miller
Modified: 2006-12-27 13:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tristan Miller 2006-05-04 05:51:47 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    SuSE RPMs

I often need to open multiple konsole tabs, each running the same program but with different arguments.  Unfortunately, there seems to be no way to do this automatically -- not even via DCOP.  What I would like is for konsole to support a command-line option similar to -e, except that instead of running the command in a new konsole window, the command is run in a new tab of an existing konsole window.  This feature is analogous to Mozilla's "-remote openURL(URL,newtab)" command-line option.

For example, the following command, when run from an existing konsole shell, would open three more tabs in the same konsole window:

[psy@polecat:~]$ for f in a.html b.html c.html;do konsole --newtab lynx $f; done

Things are trickier if more than one konsole instance is currently running and you want the command to be run in a particular window.  You could either disallow this behaviour (i.e., --newtab can be run only from within konsole and applies only to the current instance), or add another command-line option which specifies which instance the new tabs should appear in.

Incidentally, a comment in Bug 13125 states that this can be done via DCOP, but it doesn't seem to be possible in Konsole 1.6.2.  The problem is that there seems to be no DCOP function for sending a command to a konsole session.  The aforementioned comment uses an interface named sendSession, but this interface does not exist:

[psy@polecat:~]$ KONSOLE=`dcopstart konsole`
[psy@polecat:~]$ echo $KONSOLE
konsole-24158
[psy@polecat:~]$ LOCAL_SESSION=`dcop $KONSOLE konsole newSession`
[psy@polecat:~]$ echo $LOCAL_SESSION
session-2
[psy@polecat:~]$ dcop $KONSOLE $LOCAL_SESSION sendSession "echo foo"
no such function                                                                                  
[psy@polecat:~]$ dcop $KONSOLE $LOCAL_SESSION
QCStringList interfaces()
QCStringList functions()
bool closeSession()
bool sendSignal(int signal)
void clearHistory()
void renameSession(QString name)
QString sessionName()
int sessionPID()
QString schema()
void setSchema(QString schema)
QString encoding()
void setEncoding(QString encoding)
QString keytab()
void setKeytab(QString keyboard)
QSize size()
void setSize(QSize size)
[psy@polecat:~]$
Comment 1 Thiago Macieira 2006-05-08 01:04:49 UTC
konsole --script

All you want is possible with DCOP.
Comment 2 Eric Prud'hommeaux 2006-12-20 18:20:33 UTC
I note that this bug report gets reported every couple years.
  http://lists.kde.org/?l=konsole-devel&w=2&r=1&s=sendSession&q=b

konsole --script will allow me to open a new konsole with a command. What's conspicuously absent is the ability to target a konsole (by pid) and open several sessions with different commands sent to each. This was possible with sendSession.

application=$(echo $KONSOLE_DCOP_SESSION | cut -d '(' -f 2 | cut -d ',' -f 1);
for mbox in inbox public-rdf-dawg public-rdf-dawg-comments ; do
  function=$(dcop $application konsole newSession 'mutt -f mail/$mbox');
  dcop $application $function sendSession 'mutt -f mail/$mbox';
  dcop $application $function renameSession $mbox;
done

At this point, the extra arg to newSession is ignored (unless it's some keyword like "su"? possibly set in a conf file?) and sendSession is unsupported. I am using konsole 1.6.5 on KDE 3.5.5 distributed by debian package konsole-3.5.5a.dfsg.1-3 . I have not researched whether debian has specifically disabled the sendSession feature, but it seems to be frequenly reported here.
Comment 3 Justin Mason 2006-12-27 13:05:13 UTC
fyi, I just figured out why my konsoles weren't allowing me to use sendSession() too -- I'll note it here for Eric (and posterity).  

as Thiago obliquely hinted, you need to _start_ the konsoles using the --script switch for those DCOP calls to be available; if that switch was not specified, they won't allow it and the API will appear to be unsupported.