4

I use terminal a lot. I wrote a script and have it in ~/blah/script.sh now. How can I run the script from Unity (Dash?)?

A long time ago I would have used ALT-F2 and typed my command, but that doesn't do what I expect now.

Maybe modifying some $PATH var somewhere so dash can find it...? I don't want to change the dir the script is in because it's in a place where I serve various scripts for reasons.

Tips?

1 Answer 1

5

Simply create a .desktop file and save it in ~/.local/share/applications. In its most basic form:

[Desktop Entry]
Name=name_of_your_script_like_you_see_it_in_Dash
Exec=sh /path/to/script.sh
Icon=/path/to/some/icon
Type=Application

Copy it into an empty file, save it as script.desktop in ~/.local/share/applications. After log out /in, it will appear in Dash.

If the script is executable, you can replace Exec=sh /path/to/script.sh by simply: Exec=/path/to/script.sh, or if you don't have the language extension on the script: Exec=/path/to/script

Note

If the path to your script contains (folder-) names with spaces, you can simply escape it by putting the name between quotes. For example:

Exec=sh /path/with/'Folder with spaces'/to/script.sh

(spaces in the path to your icon can/should be left as they are)

4
  • and don't forget to make executable your .desktop file chmod +x ~/.local/share/applications/MYscript.desktop:) Oct 22, 2014 at 19:19
  • @KasiyA that is not necessary when you use it for Dash / Unity and store it in either ~/.local/share/applications` or /usr/share/applications. Most of the .desktop files are not in there. Oct 22, 2014 at 19:21
  • But it's necessary for me cuz that's not appear in dash if it's not executable (MAY be my home folder is encrypted) Oct 22, 2014 at 19:24
  • @KasiyA That is exceptional! Most applications install a .desktop file that is not executable. None of mine is in /.local/share/applications (and I have a lot there :) ) Oct 22, 2014 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.