Wednesday, November 30, 2005

scripting up some tabs in kde's konsole app


[root@moby bin]$ cat bipcons.sh
#!/bin/sh

SESSIONS="
d44
co-04
c62-29
co-02
co-05
d84-1
d84-2
"

KONSOLE=`dcopclient $KONSOLE_DCOP`
CURSESSION=$KONSOLE_DCOP_SESSION
for A in $SESSIONS; do
NEWSESSION=`dcop $KONSOLE konsole newSession $A`
dcop $KONSOLE $NEWSESSION renameSession $A
# your command here on the next line!
dcop $KONSOLE $NEWSESSION sendSession "console $A"
done
dcop $CURSESSION closeSession



The above shell script I have saved to a icon on my kde desktop. The icon properties run this in the command section:

/usr/local/bin/konsole --script -e ~/bin/bipcons.sh

Basically it opens a new tab for each entry in $SESSIONS, assigns the tab name to that entry ($A) and then runs a command on that entry as well. In this example, the remote console app (http://www.conserver.com). Of course that app could be anything, like ssh.

Very useful stuff. Took me a long time to dig up this information on the web, so I'm posting it here for posterity.