4

How can I change the Konsole title in Python? I found this code:

>>> import sys
>>> sys.stdout.write("\x1b]2;test\x07")

But it only works with Gnome terminal, not Konsole (on Kubuntu).

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
user962284
  • 670
  • 1
  • 12
  • 29

2 Answers2

7

I would give "\x1b]0;test\x07" a try (note the 0 instead of 2).

There is an open bug about Konsole not correctly treating xterm escape sequences; maybe it won't work at all until it is fixed.

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
niko
  • 1,816
  • 13
  • 13
  • 1
    Do you have command for Python 3? Is there any possible way rather than `os.system("echo -ne "\033]0;test\007"")`? – Ooker Jun 27 '14 at 09:16
2
dcop "$KONSOLE_DCOP_SESSION" renameSession "New title here"

This should work. You can also run the command without the renameSession part to get a list of other options that you can changed.

cstrouse
  • 288
  • 1
  • 3
  • 17