The initial name is usually set by the (code within) the application itself. You can however change it, e.g. by using xdotool
, which you would have to install first:
sudo apt-get install xdotool
Then, once it is installed, you can set another window name by (e.g.) the command:
xdotool search --name "Unity LauncherSwitcher" set_window --name "Monkey"
This will change:
into:
Note
As you can see, the command exists of:
xdotool search --name "<current_name>" set_window --name "<new_name>"
The <current_name>
has to match exactly.
Edit alternatively
From your comment, I understand the command above did not work. I tested it with different applications, and it worked...
But for a reason I do not understand, NOT with Rhytmbox
(!! might be a bug)
An alternative is to use wmctrl
, which you also would have to install:
sudo apt-get install wmctrl
Then use the command:
xprop -id "$(wmctrl -l | grep 'Rhythmbox' | awk '{ print $1 }')" -set WM_NAME "Music"
I succesfully tested it on Rhythmbox
:
Make the changes permanent?
As mentioned, the default window name is defined in the code of the application.
Changing the default window title would need to change the code. That can be done if the code is available, would need recompiling in many cases and depends on the used language, among other things. A general instruction would be quite impossible and beyond (outside) the scope of AU in my opinion.
EDIT 2
Flexibly manage/set custom window names per application from a single file
In your original question, you were wondering if there was some kind of a file to set the title of new windows of a specific application. As explained, that is not the case, however, it can be created.
In the setup below, you can very easily define on a per application base how new windows are named. Simply create a file in ~
(your home directory), named window_names.txt
. For each of the applications you want to set a specific windowname for, add a line of, subsequenty, the application and the desired window name:
A textfile, defining window names per application
gnome-terminal Monkey eats
gedit Banana
rhythmbox if he runs out of peanuts
Explanation
The setup exists of a simple background script. The script is very light, so it won't have any noticable effect on the performance whatsoever.
Once the script starts, it reads the file ~/window_names.txt
and loads the settings per application. Then it keeps an eye on newly created windows. If a window appears that belongs to one of the applications, definied in the file, it sets the window name accordingly.
How to set up
The script uses both wmctrl
and xdotool
:
sudo apt-get install wmctrl
sudo apt-get install xdotool
Copy the script into an empty file save it as setwindowname.py
Create the file ~/window_names.txt
(exactly named window_names.txt
), add your applications in the format:
<application> <window_name>
e.g.
gedit Text editor
The window name may include spaces.
Test-run the script from the terminal by the command:
python3 /path/to/setwindowname.py
If all works as expected, add it to startup applications: Dash > Startup Applications > Add
Note that in some cases, a script might break if it starts when the desktop is not fully loaded yet. If that migh be the case, the command to add to startup applications would be:
/bin/bash -c "sleep 15&&python3 /path/to/setwindowname.py"
The script
#!/usr/bin/env python3
import subprocess
import time
import os
f = os.environ["HOME"]+"/"+"window_names.txt"
change = []
lines = open(f).read().splitlines()
for l in lines:
try:
change.append([l.split()[0], (" ").join(l.split()[1:])])
except IndexError:
pass
get = lambda cmd: subprocess.check_output(cmd).decode("utf-8").strip()
curr_1 = []
while True:
try:
curr_2 = get(["wmctrl", "-lp"]).splitlines()
new = [w for w in curr_2 if not w in curr_1]
for item in new:
line = item.split(); pid = line[2]
procs = get(["ps", "-e"]).splitlines()
match = [l for l in procs if pid in l][0]
for app in [app for app in change if app[0] in match]:
subprocess.Popen(["xdotool", "set_window", "--name", app[1], line[0]])
curr_1 = curr_2
time.sleep(0.3)
except:
pass
Notes
- If the file
~/window_names.txt
is edited, the script needs to be restarted.
- It works no matter how an application is started; it also works when applications are run from the terminal / and or with
sudo
.
- It does not interefere with the the right-click option of any application.
- The script also "maintains" the window name; if another process changes the window name afterwards (opening tabs, change directories e.g.) the script sees the window as a "new window" and maintains the window name of your choice.