Open Konsole split screen on startup

When I login after a reboot, the first thing I do is open Konsole, split it into 4 views, and run btop and a tail of syslog. Then I use the other 2 split screens for other random things throughout the day.

Is it possible to have Konsole split the screen, and open btop and tail syslog without having to do it manually?

Are you using X or Wayland?

  • On X you could try the Session restore feature: Session Management
    Afaik this is not available on Wayland yet.

  • Probably a shell script that auto starts would also work

1 Like

Not sure 'bout starting it in a split view ( maybe by using a script), but starting it with predefined tabs is certainly possible. You could make a desktop application or change the launch command for konsole like konsole --tabs-from-file ~/.konsole/current-tabs. That file would look something like:

workdir: /home/john;; title: Htop;; command:htop
workdir: /home/john;; title: Ranger;; command:ranger
workdir: /home/john;; title: Cava;; command:cava
workdir: /home/john;; title: Shabbam;; command:/home/john/Scripts/
workdir: /home/john;; title: Speedtest;; command:speedtest
workdir: /home/john;; title: Gdu;; command:gdu
workdir: /home/john;; title: Inxi;; command:/home/john/Scripts/

Would look like:

1 Like

I’m using X, but the save session does not start up the programs in the Konsole window, and Firefox opens to a pseudo-previous state.

You can save a Konsole layout:

then use konsole --layout and it will start a new Konsole application with the layout ( works with splitview)

Although I’m not sure yet how to start those programs in the splitview then :confused:

1 Like

That’s correct. You can save a layout as a json file. But that will only save the layout, not the commands. It would require a script to do that. Probably with qdbus. Can’t remember really but I think I posted something about this on the old forum.

1 Like

Hello, i am trying to solve this one aswell for monitoring my system status. Found this on reddit:

For people that stumbled upon this post expecting a solution, here’s mine. It launches a new Konsole window with 4 splitted views. If you want just a one splitted view, delete the last three lines.Paste this code to a new file and make it an executable with chmod +x. You can even create a shortcut to use with KDE, just remember to add the path of the directory containing the script to the ~/.profile file so KDE shell will see it.

[link which i cannot post on KDE forums due to limitations]

{line}: {Simple explanation}

3: We launch a new konsole
4: We catch it’s pid, we need it for qdbus
6: Stops the script for 0.5 sec. You may need to make it longer, for me it was necessary because qdbus would return errors before Konsole fully launches
8: Split view vertically
9: Whenever we split the window, the focus seems to always be in the new session, so now we split the RIGHT window horizontally
10: Before this line we have a 1 window on the left and two windows on the right with the focus on the newest window (bottom-right). If we’re just gonna split view top bottom now, we would have 1 window on the left and 3 on the right. The split is always called on a window (session) that currently has the focus, that’s why this line sets the focus to the session with id 1, which is the lonely window on the left.
11. Simply split the left window horizontally.

I’ve personally added a -f flag to have an option to launch it in fullscreen, but I’ve removed it for the sake of simplicity. If someone’s interested just tell me. I hope you’ll find it helpful.

EDIT: For the reasons beyond me Reddit messes the formatting of my comment whenever I try to format this code properly, so I’ve moved it to a pastebin.

However, it does not invoke any commands, but shows how to change the focus withing the konsole. Then i found this:

I’m trying to write a script that will create a split Konsole & run a bunch of commands, similar to tmuxinator. Konsole has arguments to run commands in tabs, but the only way I found to do it in splits is via qdbus. Per this post:

  1. qdbus org.kde.konsole-<pid> /konsole/MainWindow_1 org.kde.KMainWindow.activateAction split-view-left-right
  2. Find which session you want to run the command in
  3. qdbus org.kde.konsole-<pid> /Sessions/1 org.kde.konsole.Session.runCommand "echo"

In step 3, if I use Sessions/1 it runs the command in the ‘first’ split, as expected. However, I can’t seem to figure out how to run a command in any of the others - any value other than ‘1’ throws an error.

If anyone knows how to figure out the ‘session’ needed to run a command in any of the other (non-primary) splits, I’d greatly appreciate any pointers. Sadly I’m completely inexperienced with qdbus, and haven’t turned up much after quite a bit of Googling.

On that matter, i have found this one:

qdbus org.kde.konsole-$the_pid /Windows/1 sessionList

Tried it out myself:

Hi jcns ,

i do something similar by adding the required command at the start of ~/,bashrc

Hope that helps.