this post was submitted on 12 Mar 2024
7 points (100.0% liked)

KDE

5281 readers
69 users here now

KDE is an international technology team creating user-friendly free and open source software for desktop and portable computing. KDE’s software runs on GNU/Linux, BSD and other operating systems, including Windows.

Plasma 6 Bugs

If you encounter a bug, proceed to https://bugs.kde.org, check whether it has been reported.

If it hasn't, report it yourself.

PLEASE THINK CAREFULLY BEFORE POSTING HERE.

Developers do not look for reports on social media, so they will not see it and all it does is clutter up the feed.

founded 1 year ago
MODERATORS
 

Anyone knows how to add a key-binding in konsole that binds a key combination to a sequence of actions?

Maybe, this could be achieved via a script?

In my case, I just want a key-binding to switch to a certain tab and send the command !! (last used command). This is super-useful while developing. I can do the first action with standard konsole keybinding and the second action using a qdbus command. I don't know how to put them together...

you are viewing a single comment's thread
view the rest of the comments
[–] count0@lemmy.dbzer0.com 2 points 7 months ago* (last edited 7 months ago) (1 children)

Thank you!

This is what I came up with.

  • a script that does what you need, and reads a kinda 'config file' which Konsole instance/window/session to use
  • another script that saves the current session into that config file

So you'd save the scripts somewhere you like, and run the useThisSession one in the session you'd like to be the target.

Then, you can run / bind to a shortcut / ... the runCommand script, and it will show, raise, set Session, and run the command on the target saved earlier.

useThisSession.sh:

#!/bin/bash
# useThisSession

echo MYCMD_SERVICE=$KONSOLE_DBUS_SERVICE > ~/.config/mycmdrc
echo MYCMD_SESSION=${KONSOLE_DBUS_SESSION#/Sessions/} >> ~/.config/mycmdrc
echo MYCMD_WINDOW=${KONSOLE_DBUS_WINDOW#/Windows/} >> ~/.config/mycmdrc

runCommand.sh:

#!/bin/bash
# runCommand

. ~/.config/mycmdrc

qdbus $MYCMD_SERVICE /konsole/MainWindow_$MYCMD_WINDOW showNormal
qdbus $MYCMD_SERVICE /konsole/MainWindow_$MYCMD_WINDOW raise
qdbus $MYCMD_SERVICE /Windows/$MYCMD_WINDOW setCurrentSession $MYCMD_SESSION
qdbus $KONSOLE_DBUS_SERVICE /Sessions/$MYCMD_SESSION runCommand "echo cmd"

For testing purposes, I'm using "echo cmd" instead of '!!' (note the different type of quotes) to not cause any... unintended... executions.

Running qdbus $MYCMD_SERVICE /konsole/MainWindow_$MYCMD_WINDOW will show you all methods available on the Window, eg, so you can pick&choose from those if you want different behaviour from show (& un-minimize) and raise.

EDIT: syntax adjusted to work in 'regular' bash


[–] Capricorn 1 points 7 months ago

Great! Anyway, still far from what you can get with tmux or kitty with just a line in the config...