You are not logged in.

1

Friday, May 5th 2006, 6:19am

Scripting multiple konsole tabs?

Hi KDE-Forum,

I have been trying to find an automated way to get a different man page to open on each tab in Konsole. For example, I would like "man modprobe" on tab 1 and "man modconf" on tab 2. The best I can do right now is getting one man page on one tab by using either "konsole -e" or by saving a Konsole session with a single man command. Of course I can also get all the man pages I want by putting lots of "konsole -e" statements in a shell script, but since each is in a separate window my desktop gets too cluttered.

Has anybody else solved this, or figured out a good alternative?

Thanks,
Pizzapie
Linux A. Wannabe PizzaPie

bram85

Professional

Posts: 948

Location: Eindhoven

Occupation: Software Engineer

  • Send private message

2

Friday, May 5th 2006, 12:15pm

RE: Scripting multiple konsole tabs?

Create a script like this:

Source code

1
2
3
4
5
6
konsole --script -e man ls &
sleep 5
KONSOLE=`dcop | grep konsole | tail -n 1`
SESSION=`dcop $KONSOLE konsole newSession`
sleep 1
dcop $KONSOLE $SESSION sendSession "man cd"


It opens initially a console a with the man ls command. Then, it creates with DCOP a new session and then it feeds the newly created session with the man cd command.
The sleep commands are required because the successive DCOP commands are not immediately available, but after some timeout. For example, I gave Konsole 5 seconds the time to start, so that the command newSession is available by that time.

Of course you can tweak this as much as you want, but this is the idea.
Bram Schoenmakers
KDE Netherlands (www.kde.nl)

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

3

Saturday, May 6th 2006, 4:46pm

Instead of sleep it might be possible to start a script instead of the first manpage and have this script perform the DCOP commands.
This also has the advantage that the DCOP references are set in the embedded shell's environment.

Cheers,
_
Qt/KDE Developer
Debian User

bram85

Professional

Posts: 948

Location: Eindhoven

Occupation: Software Engineer

  • Send private message

4

Saturday, May 6th 2006, 5:53pm

Between these two lines

Source code

1
2
SESSION=`dcop $KONSOLE konsole newSession`
dcop $KONSOLE $SESSION sendSession "man cd"
there should still be a sleep, because the newSession command does not finish immediately but takes n millisecs.
Bram Schoenmakers
KDE Netherlands (www.kde.nl)

5

Sunday, July 23rd 2006, 5:46am

Thanks!

Thanks guys! I tried out the script as written and it works fine! Of course there's no manpage for cd since it's a built-in. Took me a while, but at the time I just had no idea what dcop was all about. Pretty cool to finally understand this. ;)
Linux A. Wannabe PizzaPie