How can I have the software center automatically create a shortcut on my desktop every time it installs an application?
Run the script below in the background and it will automatically create a starter on your desktop on (only) newly installed software.
It also:
- checks if the new item actually is an application, meant to start from a launcher (checking for
NoDisplay=true
) - makes the launcher on your desktop executable, ready to use.
How to use
- Copy the script below into an empty file (use e.g.
gedit
), save it somewhere asmake_starter.py
. -
If you first want to test it: run it from a terminal window by the command:
python3 /path/to/make_starter.py
Install an application like you are used to. An icon should appear on your desktop after installation has finished
-
If all works fine, add it to your startup applications: Dash > Startup Applications > Add. Add the command:
python3 /path/to/make_starter.py
Note
Localized versions of Ubuntu may have a different name for "Desktop" ("Bureaublad" in Dutch). If so, replace in the line:
desktopname = "Desktop"
"Desktop" by the loacalized name.
The script
#!/usr/bin/env python3
import subprocess
import os
import time
import shutil
desktopname = "Desktop"
dr = "/usr/share/applications"
while True:
current = os.listdir(dr)
time.sleep(10)
last = os.listdir(dr)
for item in last:
if not item in current and item.endswith(".desktop"):
file = dr+"/"+item
with open(file) as src:
text = src.read()
if not "NoDisplay=true" in text:
target = os.environ["HOME"]+"/"+desktopname+"/"+item
shutil.copyfile(file, target)
command = "chmod +x "+target
subprocess.Popen(["/bin/bash", "-c", command])
This will be incredibly messy, since there might be well over a hundred application icons. The icons (actually, desktop launcher files) are usually in /usr/share/applications
. So you could run the following command in a terminal:
find /usr/share/applications -type f -name '*.desktop' -exec cp --target-directory ~/Desktop/ {} +
but this would create a copy of every single launcher on your desktop. (possibly a few hundred, depending on your environment)
You could browse /usr/share/applications
in the file manager, and manually copy them for relevant applications to the desktop. There's no automatic way to make the Software Centre do this, as far as I can tell.