Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using KDE here, but there might be a solution that works with other desktops environments too. I often am dealing with many many windows. Most windows contain many tabs (e.g. a Dolphin window with many tabs, or Firefox, Konsole, etc). The window title will change based on my current tab (which for the most part is helpful most of the time), but when working with so many windows I'd like to organize them a bit and be able to manually re-name the window, overriding the the window title that the application gives. I might name one Firefox window "Research" and other Firefox window "Documentation" to be able to easily distinguish between the windows that I've used to organize and group different tabs accordingly.

Ideally I'd be able to click on a window title bar and easily give it a custom name, but I'd settle for a solution that's slightly more cumbersome as long as it works.

I've tried wmctrl -r :SELECT: -T "Research" but that only works temporarily (the title is reverted when the application changes it, for example when switching tabs).

share|improve this question
Native KDE apps do have a --caption command-line option that lets you set the window title, but I don't think that's quite what you're looking for. – David Z Oct 13 '11 at 17:55
@SeanMadsen Heya, do you still need this? Cuz if you do, I'd love to know if you can get my script to work for you. ^^; – Owen_R Jun 16 '15 at 23:29

What you're looking for sounds like a window tagging facility. I doubt KDE has support for this, other WMs (like XMonad or DWM etc) do.

Thus one possibility to achieve this productivity boost would be to trade kwin in for XMonad and configure XMonad to do tagging. The XMonad tagging mechanism as described in the second link would be to bind a key combination to open a prompt that let's you tag the focused window. (XMonad's config is actually a Haskell-program, so don't hesitate to ask for help in #xmonad.

Edit: While I'd advise everyone to at least try a tiling WM some time, I forgot to point out that while XMonad is commonly referred to as a tiling WM, there is a "simple float"-mode. There surely are other WMs that support tagging and non-tiling layouts, but I don't know about their interoperability with KDE.

share|improve this answer

I had this exact same problem.

So I wrote a shell script that I bound to a hotkey.

When I hit the hotkey, it gets the window id of the currently active window (the one that has focus).

Then it gives you a popup dialog where you enter the title you want that window to have.

Then every time that window changes its name, it changes it back to the title you want.

To use the script, you need:

  • the fish shell
    (I wrote it in fish rather than bash cuz bash gives me a headache)

  • kdialog

  • some way to bind the script to a hotkey
    (I use xbindkeys, cuz all I had to do to get it to work was add:


(that is, window key + t)
to my /home/o1/.xbindkeysrc)

Thanks to this dude, who gave me the info on the magic xprop stuff.

(Like, a year ago, and then I never got around to writing the script til today. xD )

P.S. If any newbie finds this answer and doesn't know how to use it, just ask me and I'll walk you through it. ^^

EDIT: I updated it so that you can use it from the command line with the switches -t for title_i_want and -w for window_id.

Here's the script:


# this block is so you can use it from the command line with -t and -w
if test "$argv" != "" -a (math (count $argv)%2 == 0)
    for i in (seq 1 (count $argv))
        if test $argv[$i] = '-t'
            set title_i_want $argv[(math 1 + $i)]
        else if test $argv[$i] = '-w'
            set window_id $argv[(math 1 + $i)]
    if not test $window_id
        echo "YOU DIDN'T ENTER A `window_id` WITH `-w`,
        sleep 2

# get the id of the currently focused window
if not test $window_id
    set window_id (xprop -root _NET_ACTIVE_WINDOW | grep -P -o "0x\w+")

# get the title to force on that window

if not test $title_i_want
    set title_i_want (kdialog --title "entitled" --inputbox "type the title you want and hit enter.
to stop renaming,
just enter nothing and hit esc")

# this bit is needed for a kludge that allows window renaming
set has_renamed_before "FALSE"
set interrupt_message "WAIT WAIT I WANT A TURN BLOO BLOO BLEE BLUH BLOO" # hopefully i never want to actually use that as a title xD
xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME $interrupt_message -id $window_id

# take the output of xprop
# pipe it into a while loop
# everytime it outputs a new line
# stuff it into a variable named "current_title"
xprop -spy _NET_WM_NAME -id $window_id | while read current_title

    # cut off extraneous not-the-title bits of that string
    set current_title (echo $current_title | grep -P -o '(?<=_NET_WM_NAME\(UTF8_STRING\) = ").*(?="\z)')

    # if the current title is the interrupt message
    # AND
    # this script has renamed the window at least once before
    # then we wanna let the new name take over
    if test $current_title = $interrupt_message -a $has_renamed_before = "TRUE"
    # if title_i_want is an empty string, exit
    else if test $title_i_want = ""
        xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME "WIDNOW WILL START RENAMING ITSELF AS NORMAL" -id $window_id
    # otherwise just change the title to what i want
    else if test $current_title != $title_i_want
        xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME "$title_i_want" -id $window_id
        set has_renamed_before "TRUE"
share|improve this answer

Since there is no way to set the window title to write protect there will be no solution to that problem, since many programs reset their title upon different actions as you already have discovered.

But maybe a nice suggestion for the KDE and Gnome people ;-)

share|improve this answer

I was looking for the same thing and for the same reason. Ended up spending too much time on this, with this 70 line script.

How does it work?

  • start the script
  • click the window you want to set a title
  • and enter the title you want

Then it will start a loop in the background, check every 3 seconds, and set the title if it changes.

Warning: don't run twice on same window, script isn't perfect.

example script name:sticky-title


# stop all instance of this script if "killall" provided as first argument
if [ "$1" == "killall" ]; then
  scriptname=$(basename "$0")
  pattern="[0-9]* /bin/bash .*$scriptname$"
  pids=$(ps ax -o pid,cmd | grep -P "$pattern" | sed 's/^ *//;s/ *$//' | grep -Pv ' grep|killall$' | cut -d" " -f1)
  if [ "$pids" != "" ]; then
    kill -TERM $pids
    echo "$(echo '$pids' | wc -l) instances stopped"
    echo "None found to stop"
  exit 0

# ask for window
echo -en "\nClick the window you want to set its title "
id=$(printf %i $(xwininfo | grep 'Window id' | cut -d" " -f4))

# fail if no window id
if [ "$id" == "" ]; then
  echo 'Error: Window id not found'
  exit 1
  echo "- Got it"

# ask for title
read -e -p "Enter target title: " title

# fail if no title
if [ "$title" == "" ]; then
  echo "Error: No title to set"
  exit 1

# define loop as a function, so we can run it in background
windowByIdSetStickyTitle() {
  local id title curr_title

  while true; do
    # get current title
    curr_title="$(xdotool getwindowname $id 2>/dev/null)"

    # exit if we can't find window anymore
    if [ $? -ne 0 ]; then
      echo "Window id does not exist anymore"

    # update title if changed
    if [ "$curr_title" != "$title" ]; then
      xdotool set_window --name "$title" $id

    # needed else you will eat up a significant amount of cpu
    sleep 3

# infinite loop
windowByIdSetStickyTitle $id "$title" &

# done
echo "Sticky title set"
exit 0
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.