I actually made a script for that. It places the icon down in the launcher, but with a minor change, you can put it at the top (or any other position) as well.
As it is, it is in python2, but simply change the shebang to #!/usr/bin/env python3
if you'd like to use it as python3. The code is identical.
To use it, the .desktop file needs to be in either /usr/share/applications
or in ~/.local/share/applications
, but usually that is the case.
How to use
- copy the script below, save it as
launcher_add.py
- make it executable
Run it by the command:
/path/to/launcher_add.py name_of_desktopfile.desktop
you have to use the filename of the .desktop file, without the path.
The script
#!/usr/bin/env python
import subprocess
import sys
desktopfile = sys.argv[1]
def current_launcher():
get_current = subprocess.check_output(["gsettings", "get", "com.canonical.Unity.Launcher", "favorites"]).decode("utf-8")
return eval(get_current)
def add_new(desktopfile):
curr_launcher = current_launcher()
last = [i for i, x in enumerate(curr_launcher) if x.startswith("application://")][-1]
new_icon = "application://"+desktopfile
if not new_icon in curr_launcher:
curr_launcher.insert(last, new_icon)
subprocess.Popen(["gsettings", "set", "com.canonical.Unity.Launcher","favorites",str(curr_launcher)])
else:
pass
add_new(desktopfile)
The script prevents multiple occasions in the launcher list of the same application, which would cause corruption of he list.
Best Answer
Overview
This answer gives two potential answers - Drawers and Quicklists
Drawers
Drawers is available via a PPA for 12.04:
Launch Drawers from Dash. For you drawer, drag and drop the created icon from
~/.local/share/applications
.Launch your drawer - then you can drag and drop your favourite applications from the Dash onto the drawer.
Graphical Quicklists
The default unity method to launch multiple options is through the use of quicklists - right-click a launcher icon to show a menu of options for that launcher icon.
The creation of quicklist using a graphical method for 12.04 is available using MyUnity
myunity
This option allows you to create quicklists - quicklists are a submenu that are displayed when you right-click a launcher icon.
The creation of quicklist using a graphical method for 11.04 is work-in-progress - for example - the Unity Launcher Editor
This works in Natty (ubuntu 11.04) - but due to the python version change, does not work (as at the time of writing this) in oneiric (ubuntu 11.10)
to install
to run
Manual creation of quicklists
Fortunately, it is simple to create quicklists manually as well. A quicklist is a .desktop file containing at the minimum the following:
Let's break this down to the areas you should change (working from top to bottom of the example).
Icon=
: this is the graphical picture file found in/usr/share/icons
Name=
: this is the tooltip you see when you hover over the launcher iconExec=
: this is the default executable run when you left click the launcher iconX-Ayatana-Desktop-Shortcuts=
: this is a semi-colon separated list of groups.Each group is a quick-list menu option under the entry
[group_name Shortcut Group]
example_apps
this is the name of the group in theX-Ayatana-Desktop-Shortcuts
fieldName=
: this is the quicklist menu textExec=
: this is the executable run when choosing the quicklist entry.desktop files should exist in the local folder
~/.local/share/applications
If it doesn't already exist create this folder:
Create a file in the folder - for example myquicklist.desktop and drag-and-drop this file from Nautilus into the Unity Launcher.
mimic XFCE launcher
The default XFCE action when clicking on the launcher button is to run an executable. For our launcher you could default to the calculator
The other action possible in the XFCE launcher is to just display the list of launcher items. Unfortunately in Unity you cannot do this - it must be a right-click.
The default
Exec=
must run something - for example you could use this to display a quick pop-up dialog reminding you to right click:Example
You gave the following examples that you wanted:
Exec=gnome-screenshot -i
Exec=xfce4-dict
Exec=gcalctool
Thus your example .desktop file would look like: