Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Thanks, Michael
Anno domini 2019 Tue, 22 Oct 12:38:35 -0500 Michael scripsit:
Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Thanks, Michael
Not on the easy way. But you could do some shell magic. First start konsole with enhanced dcop capabilities: $ konsole --script
Then you can send command to konsole with dcop, e.g. execute "ls -l" (konsole-16979 will definitly be different whan you try - and watch the linebreak inside the ""):
$ dcop konsole-16979 session-1 feedSession "ls -l "
So in theory you can get that running. When you search the archive, you'll find something simillar built for a non-sessionaware exitor (xs? xe? sorry ....)
Nik
Dne út 22. října 2019 Michael napsal(a):
Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Thanks, Michael
Hi Michal,
in the Konsole you can create your own Sessions. Opening such a Session executes the command set in Session configuration. And then, when saving a TDE session, a Konsole will remember which Session was open on which tab.
Cheers
Dne út 22. října 2019 Michael napsal(a):
Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Thanks, Michael
On Tuesday 22 October 2019 12:50:22 pm Dr. Nikolaus Klepp wrote:
Not on the easy way. But you could do some shell magic. First start konsole with enhanced dcop capabilities: $ konsole --script
Then you can send command to konsole with dcop, e.g. execute "ls -l" (konsole-16979 will definitly be different whan you try - and watch the linebreak inside the ""):
$ dcop konsole-16979 session-1 feedSession "ls -l "
On Tuesday 22 October 2019 12:52:56 pm Slávek Banko wrote:
in the Konsole you can create your own Sessions. Opening such a Session executes the command set in Session configuration. And then, when saving a TDE session, a Konsole will remember which Session was open on which tab.
Sessions, Profiles, oh My! Konsole you’re just a big pita...
Nothing will restore Konsole to a perfect copy of itself, except for auto-restart upon logout. If you close it, even profiles won’t get you back to exactly where you where. If we could somehow use the saved session in .trinity/share/config/session, this would be a lot easier. (See [1] for how to “rescue” most of a setup from another PC.)
Since no one thing would get me where I’m trying to go I borrowed both of your’s code and thoughts.
Thanks to both Nik and Slávek! I doubt I would have found all the pieces to get this to work otherwise.
Best All, Michael
How to Guide to have Konsole open with exactly what you want and where.
- First completely fix up Konsole how you want it. Everything! Tab titles, colors, widow size and location, ...
- Then save a Profile. Konsole > Settings > Save Sessions Profile > global (Change ‘global’ to whatever name you like)
- Easiest to use kdcop to get Height,Width, and other information # kdcop &
Or command line if you want to use that (I snipped much junk):
michael@local [~]# dcop | grep kons konsole-13221 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 height 633 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 width 1090 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 x 822 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 y 0
- Modify and save a copy of the shell script below. Make it executable, and add a TDE menu item or Panel button for it as desired. The sleep is needed (even on my AMD Ryzen 7 2700X)
Shell script: #!/bin/bash
konsole --script --profile global & PID=`echo $!` # echo $PID # dcop | grep kons sleep 2s
dcop "konsole-$PID" session-1 feedSession "/home/michael/common/bin/ssh01i " dcop "konsole-$PID" session-2 feedSession "/home/michael/common/bin/ssh03i " dcop "konsole-$PID" session-3 feedSession "/home/michael/common/bin/ssh04i " dcop "konsole-$PID" session-4 feedSession "su - " dcop "konsole-$PID" konsole-mainwindow#11 resize 1090 633 dcop "konsole-$PID" konsole-mainwindow#11 move 822 0
###EOF##########################
[1] You have your perfect Konsole setup on some other machine?: (This won’t start your prior running programs though)
- Log out of TDE (old machine) - rsync the old machine’s .trinity/share/config directory somewhere local on the new machine
- Login to TDE (new machine) - Have Konsole open - Log out of TDE - CTR-ALT-F1 - Log in as you - cd (make sure you’re in your user’s root) - grep -i "konsole" .trinity/share/config/ksmserverrc - copy your other machine’s konsole session file over the one listed in ksmserverrc * - exit - CTR-ALT-F7 - Log in to TDE - Welcome to the magic of TDE restart/reload...
* Example: (Since the filenames are so long, I added 2 blank lines between each for readability.)
cp
/home/m2/michael/.trinity/share/config/session/konsole_10616e6f6e000146717061500000152190023_1564505343_595166
/home/michael/.trinity/share/config/session/konsole_1028c1d320b210000154648525000000265210025_1565129749_505478
Anno domini 2019 Tue, 22 Oct 15:24:14 -0500 Michael scripsit:
Dne út 22. října 2019 Michael napsal(a):
Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Thanks, Michael
On Tuesday 22 October 2019 12:50:22 pm Dr. Nikolaus Klepp wrote:
Not on the easy way. But you could do some shell magic. First start konsole with enhanced dcop capabilities: $ konsole --script
Then you can send command to konsole with dcop, e.g. execute "ls -l" (konsole-16979 will definitly be different whan you try - and watch the linebreak inside the ""):
$ dcop konsole-16979 session-1 feedSession "ls -l "
On Tuesday 22 October 2019 12:52:56 pm Slávek Banko wrote:
in the Konsole you can create your own Sessions. Opening such a Session executes the command set in Session configuration. And then, when saving a TDE session, a Konsole will remember which Session was open on which tab.
Sessions, Profiles, oh My! Konsole you’re just a big pita...
Nothing will restore Konsole to a perfect copy of itself, except for auto-restart upon logout. If you close it, even profiles won’t get you back to exactly where you where. If we could somehow use the saved session in .trinity/share/config/session, this would be a lot easier. (See [1] for how to “rescue” most of a setup from another PC.)
Since no one thing would get me where I’m trying to go I borrowed both of your’s code and thoughts.
Thanks to both Nik and Slávek! I doubt I would have found all the pieces to get this to work otherwise.
Best All, Michael
How to Guide to have Konsole open with exactly what you want and where.
- First completely fix up Konsole how you want it.
Everything! Tab titles, colors, widow size and location, ...
- Then save a Profile.
Konsole > Settings > Save Sessions Profile > global (Change ‘global’ to whatever name you like)
- Easiest to use kdcop to get Height,Width, and other information
# kdcop &
Or command line if you want to use that (I snipped much junk):
michael@local [~]# dcop | grep kons konsole-13221 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 height 633 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 width 1090 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 x 822 michael@local [~]# dcop konsole-13221 konsole-mainwindow#11 y 0
- Modify and save a copy of the shell script below.
Make it executable, and add a TDE menu item or Panel button for it as desired. The sleep is needed (even on my AMD Ryzen 7 2700X)
Shell script: #!/bin/bash
konsole --script --profile global & PID=`echo $!` # echo $PID # dcop | grep kons sleep 2s
dcop "konsole-$PID" session-1 feedSession "/home/michael/common/bin/ssh01i " dcop "konsole-$PID" session-2 feedSession "/home/michael/common/bin/ssh03i " dcop "konsole-$PID" session-3 feedSession "/home/michael/common/bin/ssh04i " dcop "konsole-$PID" session-4 feedSession "su - " dcop "konsole-$PID" konsole-mainwindow#11 resize 1090 633 dcop "konsole-$PID" konsole-mainwindow#11 move 822 0
###EOF##########################
[1] You have your perfect Konsole setup on some other machine?: (This won’t start your prior running programs though)
- Log out of TDE (old machine)
- rsync the old machine’s .trinity/share/config directory somewhere local on
the new machine
- Login to TDE (new machine)
- Have Konsole open
- Log out of TDE
- CTR-ALT-F1
- Log in as you
- cd (make sure you’re in your user’s root)
- grep -i "konsole" .trinity/share/config/ksmserverrc
- copy your other machine’s konsole session file over the one listed in
ksmserverrc *
- exit
- CTR-ALT-F7
- Log in to TDE
- Welcome to the magic of TDE restart/reload...
- Example:
(Since the filenames are so long, I added 2 blank lines between each for readability.)
cp
/home/m2/michael/.trinity/share/config/session/konsole_10616e6f6e000146717061500000152190023_1564505343_595166
/home/michael/.trinity/share/config/session/konsole_1028c1d320b210000154648525000000265210025_1565129749_505478
:-)
Now I need a time machine back to 2008, when i needed just that and could not get my mind twisted enought to do it ...
Nik
On 10/22/2019 12:38 PM, Michael wrote:
Is this possible?
Have several tabs open in Konsole. Upon (re)login to TDE have program A automatically run in tab A, program B automatically run in tab B, program C automatically run in tab C?
Yes, this is quite possible and you use dcop to do it. I have console with 10-tabs (5-local/5-remote) session that I restore each time I start TDE/KDE. I wrote a script (that I have assigned to a button on the QuickLaunch menu to invoke)
The script is just a bash script that talks to dcop which talks to konsole.
Simple really:
#!/bin/bash
kid=$(dcop "konsole*") ## get konsole_id (if konsole running)
test -z "$kid" && { ## if not running kstart konsole --script ## start 1st session (add --iconify to start minimized) # kstart --iconify konsole --script ## start 1st session minimized) sleep 1 ## wait for start kid=$(dcop "konsole*") ## get konsole_id declare -i tries=0 while test -z "$kid" -a "$tries" -lt '10' do sleep 0.5 kid=$(dcop "konsole*") ((tries++)) done test "$tries" -eq '10' && { printf "error: kstart konsole failed.\n" exit 1 } }
Then you can use ps and awk to check that the only konsole running is the one you just started (and you can distinguish between them) Switch to the 1st konsole session:
sid1=$(dcop $kid konsole sessionId 1) ## get 1st session_id sid=$(dcop $kid konsole currentSession) ## get currentSession
## validate 1st session active test "$sid" != "$sid1" && { dcop $kid konsole activateSession "$sid1" ## switch to 1st session printf "warning: sid (%s) != sid1 (%s)\n" "$sid" "$sid1" >&2 sid="$sid1" }
Then I simply have an array of ssh_sessions I loop over opening in a new tab (session) in konsole. Similar to:
## open rename/open remaining sessions while test "$idx" -lt "$scount" do name=${sessions[$((idx++))]} ## get session name & command cmd=${sessions[$((idx++))]}
dcop $kid $sid renameSession "$name" ## set name & send cmd sleep 0.1 dcop $kid $sid sendSession "$cmd" sleep 0.1
if test "$sidx" -lt "$nsessions" ## session index -lt current number then dcop $kid konsole nextSession ## switch to nextSession & get id sid=$(dcop $kid konsole currentSession) elif test "$idx" -lt "$scount" then ((nsessions++)) sid=$(dcop $kid konsole newSession) ## create new session while test "$(dcop $kid konsole sessionCount 2>/dev/null)" -lt "$nsessions" do sleep 0.1 done fi ((sidx++)) done
## switch to first session to begin dcop $kid konsole activateSession "$sid1" ## switch to 1st session
You can do something similar for any program in any tab. The key to getting familiar with dcop and finding out what capabilities are available for any KDE3 app is to just open konsole and type
$ dcop
It will list the applications dcop can communicate with. You can find your konsole session, (mine is konsole-3380) and then simply type
$ dcop konsole-3380 qt KBookmarkManager-/home/david/.kde/share/apps/konsole/bookmarks.xml KBookmarkNotifier MainApplication-Interface konsole (default) konsole-mainwindow#1 ksycoca session-1 session-10 session-2 session-3 session-4 session-5 session-6 session-7 session-8 session-9
And of course then to see what is available by default:
$ dcop konsole-3380 konsole QCStringList interfaces() QCStringList functions() void feedAllSessions(QString text) void sendAllSessions(QString text) int sessionCount() QString currentSession() QString newSession() QString newSession(QString type) QString sessionId(int position) void activateSession(QString sessionId) void nextSession() void prevSession() void moveSessionLeft() void moveSessionRight() bool fullScreen() void setFullScreen(bool on) ASYNC reparseConfiguration()
and you can just work your way down adding the next level of function, etc.. to get exactly what you need, e.g.:
$ dcop konsole-3380 konsole sessionCount 10
Now just weave that into a script for whatever you need to launch (been great for 5 years plus here, hadn't thought about it since -- until I saw you post)