Change Konsole title via Python

跟風遠走 提交于 2019-12-22 08:21:07

问题


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


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/10919696/change-konsole-title-via-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!