This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to doubleclick to execute shell script

Tags: None
(comma "," separated)
rdowning
Registered Member
Posts
3
Karma
0
Am running Linux Mint 17.2 with KDE 4.14.2.

How can I double click on a .sh file to execute it such as in Konqueror, or even better, create a desktop shortcut to execute it, such as studio.sh to bring up Android Studio?

I an only able to execute ./scriptname.sh in terminal. Otherwise it does nothing.
User avatar
Terminus
Registered Member
Posts
24
Karma
0
OS
Well you could do it a few ways.

1. The first way would be to set the default program to open .sh programs to bash, zsh or shell script interpreter. Warning though all .sh will run by default instead of opening in a text editor and could pose a security risk if you go clicking without looking what you are running. Dolphin will warn you.

    To do this right click the .sh
    Hover over open with
    click on other
    Under open with type bash (or what ever shell you like)
    Then check run in terminal
    if you need the terminal output when you are done check do not close
    to make the change stick check remember application association for this type of file

You should now be able to run the .sh by clicking

2. You could add it to your applications menu. This can be done by right clicking the application launcher and clicking edit applications and click new.

3. If you want it on your desktop you could make a .desktop file

Code: Select all
[Desktop Entry] 
Version=1.0 
Exec=/home/yourname/bin/someshell.sh
Name=Android Studio
GenericName=Android Studio 
Comment=Loads Android Studio
Encoding=UTF-8 
Terminal=true 
Type=Application 
Categories=Application;Development;
Icon=/someicon.png
rdowning
Registered Member
Posts
3
Karma
0
I tried #2 and #3 and they did not work. That is why I thought there must be some universal capability that had to be turned on. I will try #1 and then retry #2 and #3 this evening. Thanks for the info.
rdowning
Registered Member
Posts
3
Karma
0
Ok, still won't work. Double click seems to do nothing. Right clicking and selecting to open with bash yields the following:

ERROR: Cannot start Android Studio\nNo JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation

However, if I execute ./studio.sh from a terminal window it has no problem finding a valid JDK installation.

Also, bash_profile reads as follows:

# .bash_profile

JAVA_HOME=/home/rvd/jdk1.7.0_79
JDK_HOME=/home/rvd/jdk1.7.0_79

export JAVA_HOME
export JDK_HOME

so, they are indeed both there.

What would be involved in downgrading to an older KDE where these things worked? Unfortunately I don't remember what KDE I was using in PCLinuxOS where everything worked fine.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]