skip to Main Content

I am new to Linux and I have a problem with the shortcut which I want to create on the Desktop for the script. I’m using just one line of the script because I want to understand how to create a shortcut that will run any .sh script from the Desktop position.
I allowed Launching and also I see for one second that terminal is open, but after it is closing and I don’t see the output for example in the terminal…
Could you please advise???

In the picture you will see the script and also [Desktop Entry]

2

Answers


  1. After executing the script, the terminal will close. There are different ways to achieve what you want

    Login or Signup to reply.
  2. You can simply put a read -p "Press Enter to Continue" message at the end of Shell Script or put a simple sleep 5 i.e. delay of 5 seconds or any amount of delay you want

    Example 1 with read:

    #!/bin/bash
    
    echo "Hello World..."
    read -p "Press Enter to Continue"
    

    This will ask you for a key press and waits for you to press any key on keyboard

    Example 2 with sleep:

    #!/bin/bash
    
    echo "Hello World..."
    sleep 5
    

    This will simply wait for 5 seconds and automatically exits

    Also, ensure that the .desktop file has executable permissions

    sudo chmod a+x /usr/share/applications/Hello.desktop or sudo chmod a+x ~/.local/share/applications/Hello.desktop depending on where you have saved the .desktop file

    Reference: https://askubuntu.com/a/230374/679241

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search