Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Konsole title via Python

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).

like image 748
user962284 Avatar asked Jan 16 '23 11:01

user962284


2 Answers

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.

like image 90
niko Avatar answered Jan 28 '23 11:01

niko


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.

like image 30
cstrouse Avatar answered Jan 28 '23 12:01

cstrouse