How can I add a bash script to the Unity launcher? [duplicate]
I created one for Gnome Screensaver, and saved it to: ~/.local/share/applications/
you may need to create this directory:
mkdir ~/.local/share/applications (if required)
screensaver.desktop
[Desktop Entry]
Name=Activate Screensaver
Comment=
Exec=gnome-screensaver-command -a
Icon=screensaver
Terminal=false
Type=Application
StartupNotify=true
Then simply search in Dash for the 'Name', and move icon to launcher.
Use
gnome-desktop-item-edit ~/Desktop/ --create-new
in terminal to create a launcher in desktop. I've tried it in Ubuntu 12.04 and it works.
Actually, it works only if you have gnome-shell installed. But I have tried and found that even if only gnome-desktop-item-edit
is present, it can still work.
Launchers are *.desktop
files, and making them is fairly easy. I do agree with you in that Unity should create a working launcher automatically, but in this case it looks like you will have to create the launcher yourself.
To create a launcher, just follow these steps:"
- Right click on your desktop, and select Create Launcher
- Name it as you like, and select for it the icon of your preference
- In the Location entry, enter the location to your
*.sh
script - remember that it must be executable or else the launcher will not be able to open your application - The comment, needless to say, is optional to enter
Check out this guide on creating launchers for more information.
Once that you have your launcher working, move it to ~/.local/share/applications/
(where you will find other launchers perhaps), launch the application and pin it to Unity. I think it will work afterwards, if not let me know.
Not refuting the previous answers in any way, but there are a couple of other options you may or may not which to consider:
If you have too many icons in your launcher and you don't like the accordian effect, you can add multiple executables accessible through "right clicking" one icon. Search "unity shortcut group" or "unity quicklist" for lots of examples.
You can access scripts directly from your desktop via "right click" context menu. Search "Nautilus Scripts" for howtos and examples. These can be especially useful for context specific actions on objects you see/select in the nautilus filesystem browser (for example, I use scripts to "open a terminal here" and "Edit with VIM" a lot).
One solution is no better than the other ... just a few more options to consider depending on the specifics of what you want.