Shell Script Desktop Shortcut

16,360

Both the desktop entry and the shell script should have executable permissions. Do:

$ chmod +x path_to_shortcut/shortcut.desktop
$ chmod +x path_to_script/test.sh  

Another way to change permissions for a script is to right click it, go to Properties > Premissions and check Allow executing file as program.

Permissions

Share:
16,360

Related videos on Youtube

DeadSix17
Author by

DeadSix17

Updated on September 18, 2022

Comments

  • DeadSix17
    DeadSix17 over 1 year

    So I tried making a desktop shortcut which executes a very simple shell script. But when i double click/right click->execute it, it does nothing. (or at least I think it does nothing)

    heres how my shortcut and shell script looks: Note the shortcut has "Terminal" set to 1, and i hope that means that it opens the shell script in a new terminal window.. (i have a couple terminals already open, which arent ready for usage (have scripts running))

    Shortcut:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Test
    Comment=Test
    Exec=/home/(myusername)/test/test.sh
    Icon=utilities-terminal
    Terminal=true
    StartupNotify=false
    GenericName=Test
    

    Shell Script:

    #!/bin/sh
    # (I tried both, /bin/bash and /bin/sh)
    echo "hi"
    
  • DeadSix17
    DeadSix17 about 11 years
    it does not fully work but it does execute now. But is that even the right way? I used the right click, create launcher button.. shouldnt that automatically give my launcher execution permission.. hows that user friendly.. thats also the reason why i didnt give it +x myself, i only gave +x to test.sh
  • ignite
    ignite about 11 years
    You have to give executable permissions explicitly, see edit to my answer.
  • DeadSix17
    DeadSix17 about 11 years
    i told you i did that from the begin (just not on the shortcut).. the problem is that the script doesnt open in a new Terminal, also adding this command opens a terminal though: "/usr/bin/xfce4-terminal" so i thought hm.. probably terminal allows argument 1 to be a shell script .. and i tried that.. but doesnt work. So to make it more easy to understand what i need, i want a Shortcut that opens a NEW! Terminal and runs a specific Shell Script in it. (I did add execution permissions to both, the shortcut and the Script) Also tried running terminal itself and gave it a shell script path as arg
  • ignite
    ignite about 11 years
    As you have set Terminal=True, your script should have opened in a terminal itself or you want two terminals?
  • DeadSix17
    DeadSix17 about 11 years
    No, i want a single terminal to open even if there are already X ammount of terminals open.
  • ignite
    ignite about 11 years
    It does open a new terminal, irrespective of how many terminals are already open. However you will see it for a very short time, as it executes almost immediately.
  • David Foerster
    David Foerster over 9 years
    While this certainly works, I don't see the point of jumping through all these hoops when marking the script executable and symlinking it to the desktop should do.
  • Jenya G
    Jenya G over 9 years
    Only if that worked all of the time: -rwxrwxrwx 1 jeneag jeneag 5889 Aug 8 13:39 studio.sh It is executable, but still opens in vim/editor. Not to mention that external/internal mounted HDD unless property defined in /etc/fstab with ntfs-3g exec,users,permissions... lines it will be owned by root:root and chmod +x would not do anything at all.
  • muru
    muru over 9 years
    You probably forgot to configure the file browser to run executable files instead of viewing/editing them.
  • David Foerster
    David Foerster over 9 years
    That and does the shell script start with a shebang (though /bin/sh is the default interpreter for files without one)?
  • Jenya G
    Jenya G over 9 years
    Yes it starts with #!/bin/sh. As far as configuring, nothing was changed from 12.x ubuntu when I did an upgrade to 14.04 2 days ago. Last couple of releases Ubuntu makes me and my dev friends spend 1+ hours on configurations to get rid of all of that fancy stuff so desktop would be useful for software development.