1

One can send text via dbus to the terminal emulator konsole as followed:

qdbus org.kde.konsole /Sessions/1 sendText "hello"

However I want to remotely clear the screen of the specified terminal window. So I tried:

qdbus org.kde.konsole /Sessions/1 runCommand "clear"

Does partly what I want. Only problem: The screen doesn't get cleared when there is a process running.

In the terminal emulator, in this case the key combination "Ctrl + L" would do the job.

So I'm trying to send a string with escape characters for this shortcut. Is this going to work? This, however doesn't do;

qdbus org.kde.konsole /Sessions/1 sendText "\033[2J"

(runCommand neither)

Anton Harald
  • 5,772
  • 4
  • 27
  • 61

1 Answers1

1

This is working for me:

qdbus org.kde.konsole /Sessions/1 sendText $'\014'

First, to produce a character from its octal code, the syntax "\033" would work in C but not in Bash.

Second, while "ESC [ 2 J" is a VT100 code to Erase Screen, it work for me only if I echo $'\033[2J', and that will not work if a command is running.

Third, Ctrl-L will work if a program is expecting input from a terminal (like irb or python do), but it will not work for a while sleep 1; do echo Still running; done loop.

Martin Vidner
  • 2,307
  • 16
  • 31