Ubuntu 14.04 在桌面上双击运行shell 脚本文件

 http://askubuntu.com/questions/465531/how-to-make-a-shell-file-execute-by-double-click

 

To run your script by double clicking on its icon, you will need to create a .desktop file for it:

[Desktop Entry]
Name=My script
Comment=Test hello world script
Exec=/home/user/yourscript.sh
Icon=/home/user/youricon.gif
Terminal=false
Type=Application

Save the above as a file on your Desktop with a .desktop extension. Change /home/user/yourscript.sh and /home/user/youricon.gif to the paths of your script and whichever icon you want it ot have respectively and then you'll be able to launch by double clicking it.


Specifically, for your situation, you need to do:

  1. Create a script that runs mono LOIC.exe. To do so, create a new text file with these contents:

    #!/bin/bash
    mono /home/logan/.loic/LOIC.exe
    

    Save this as /home/locan/run_loic.sh and then run this command to make it executable (or right click => properties and choose "Allow executing file as program"):

    chmod +x /home/logan/.loic/LOIC.exe
    
  2. Create a .desktop file that launches that script. Create a new text file on your Desktop called run_loic.desktop with these contents:

    [Desktop Entry]
    Name=Run LOIC
    Comment=Run LOIC
    Exec=/home/logan/run_loic.sh
    Icon=
    Terminal=false
    Type=Application
    
shareimprove this answer

 

 

 

http://forum.ubuntu.org.cn/viewtopic.php?p=1861292

 

Thread: Opening .sh files with double click?

 

  • Thread Tools
  1. bdh2991 is offline5 Cups of Ubuntu
    Join Date
    Aug 2014
    Beans
    20

    Opening .sh files with double click?

    I just install PyCharm on ubuntu 14 and by default when i double click it opens the .sh file with gedit. How could I make it to just run the program when i double click?
  2. cariboo's Avatar
    cariboo is offlineCaffeine Fueled
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Opening .sh files with double click?

    To run executable files from Nautilus (Files) go to the Edit menu and select Preferences->Behaviour, and under Executable Text Files select Ask each time
  3. CaptainMark's Avatar
    CaptainMark is offlineTall Cafè Ubuntu
    Join Date
    May 2009
    Location
    Fareham, UK
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Opening .sh files with double click?

    Of course this only works if your script IS executable, check in the files properties.
    Catch me on Freenode - imark
  4.  

 

posted on 2015-05-19 11:31  okgogo2000  阅读(851)  评论(0编辑  收藏  举报