The naming is probably coded in nautilus, and hard to change.
What can be done however is to automatically fix it, either without any action from your side, or with a shortcut key. The only limitation is that it would work with a specific set of directories, such as the desktop and an arbitrary number of additional directories (of your choice).
automatically becomes:
What it does
The proposed solution is, at your choice, either:
- a background script, automatically looking for "faulty" -named
.desktop
files and renaming them immediately and automatically, or:
- a script, called by a shortcut key combination, doing exactly the same, but only whenever you press the key(s)
The script; background version
I tested the script on processor load, and I could not notice any extra activity (using system monitor) on my elderly system (at least 6-7 years old).
Background version
#!/usr/bin/env python3
import time
import os
import sys
dirs = sys.argv[1:]
# ---you might need to edit the string below to your local (language) version
edit_out = "Link to"
# ---
def edit_link(dr, newfiles):
for f in newfiles:
file = dr+"/"+f; text = open(file).read().splitlines()
for i, l in enumerate(text):
if all([l.startswith("Name="), edit_out in l]):
text[i] = text[i].replace(edit_out+" ", "")
open(file, "wt").write("\n".join(text))
files1 = []
while True:
time.sleep(2)
for dr in dirs:
files2 = os.listdir(dr)
newfiles = [f for f in files2 if all([not f in files1, f.endswith(".desktop")])]
edit_link(dr, newfiles)
files1 = files2
- Copy it into an empty file
- Save it as
rename_links.py
Change if necessary in the line:
edit_out = "Link to"
the string "Link to"
by the localized string in your language ("Verwijzing naar"
in Dutch)
Test- run it by the command:
python3 /path/to/rename_links.py <directory_1> <directory_2> (etc.)
where you can add as many directories as you like (use quotes if the directory contains spaces)
If all works fine, add it to your startup applications: Dash > Startup Applications > Add the command:
python3 /path/to/rename_links.py <directory_1> <directory_2>
Shortcut version
#!/usr/bin/env python3
import os
import sys
dirs = sys.argv[1:]
edit_out = "Link to"
def edit_link(dr):
files = os.listdir(dr)
for f in files:
if f.endswith(".desktop"):
file = dr+"/"+f; text = open(file).read().splitlines()
for i, l in enumerate(text):
if all([l.startswith("Name="), edit_out in l]):
text[i] = text[i].replace(edit_out+" ", "")
open(file, "wt").write("\n".join(text))
for dr in dirs:
edit_link(dr)
The set up is exactly the same as the background version, apart from [5.]
:
If all works fine, add the script to a shortcut key: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
python3 /path/to/rename_links.py <directory_1> <directory_2>
Explanation
The name, as it appears on your desktop, is not the file -name, but the name, as defined in the Name=
line of the .desktop
file.
The script looks into possible .desktop
files in the directories, you used as an argument. If it finds a line, starting with Name=Link to
, it replaces (removes) Link to
+ one space, effectively renaming the visible name of the launcher on your desktop.
Edit
Looking for a "native" solution, I tried Mozilla's add-on Deskcut to see what it does with the name of the link. On both 14.04 and 15.04 it did totally nothing however.