2

I want to make a button on my lxpanel to launch a program that prints out Hello World! in a pop-up lxterminal, so I use the technique that I successfully implemented before in Debian 7, which is:

  1. gedit /bin/hello.sh (contents below):

    #!/bin/bash
    echo 'Hello World!';
    
  2. gedit /usr/share/applications/hello1.desktop (below):

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Hello1
    Comment=Test the terminal running a command inside it
    Exec=lxterminal -e "/bin/hello.sh"
    StartupNotify=true
    Icon=utilities-terminal
    Terminal=true
    Categories=Utility;
    
  3. Last I chown and chmod both of the above files as below:

    -rwxr-xr-x 1 a adm 230  1月  1 13:02 /usr/share/applications/hello1.desktop*
    -rwxr-xr-x 1 a adm 240  1月  1 12:57 /usr/share/applications/hello1.desktop~*
    -rwxr-xr-x 1 a adm 194  1月  1 12:04 /usr/share/applications/hello.desktop*
    -rwxr-xr-x 1 a adm 195  1月  1 12:03 /usr/share/applications/hello.desktop~*
    -rwxrwxr-x 1 a adm  87  1月  1 12:35 /usr/share/applications//bin/hello.sh*
    -rwxrwxr-x 1 a a    87  1月  1    12:25 /usr/share/applications//bin/hello.sh~*
    -rwxrwxr-x 1 a adm 134 12月 13 09:56 /usr/share/applications//bin/hello_world.sh*
    

Unfortunately no matter what I do, the hello1.desktop file only can open a blank lxterminal, and there is no output.

I am running Lubuntu 14.04 and have followed the following tutorials to link a desktop file to a *.sh script program:

I also made the following variations to hello1.desktop:

  • line 10 (last line) - I also tried it without a semi-colon.
  • line 9 (the "Terminal" line) - tried "false"
  • line 6 (the "Exec" line) - tried these:

    Exec=sh /bin/hello.sh;
    Exec=lxterminal -e “/bin/hello.sh”
    Exec=/bin/hello.sh
    Exec=sh -c /bin/hello.sh
    Exec=lxterminal -x sh -c 'echo hello'
    Exec=sh -c 'gnome-terminal echo hello'
    Exec=sh -c 'echo hello'
    Exec=sh /bin/hello.sh
    Exec=sh -c /bin/hello.sh
    

But in the end all are the same (except when Terminal=false on line 9 there is no terminal, obviously).

I can see hello1 under System -> Accessories, but when I click on it still just a blank screen pops out. In debian 7.5 LXDE wheezy this is really easy to do successfully, but what is wrong in Lubuntu 14.04 to make it so much more difficult?

Andrew

wjandrea
  • 14,504
afc888ny
  • 103

1 Answers1

2

I have managed to duplicate your problem and have a solution.

As your research has told you, your original problem was having:

Terminal=true

together with:

Exec=lxterminal -e /bin/hello.sh

The only problem is, that when you use:

Terminal=false

the terminal closes after executing the script, though it does actually run your script. As your script produces so little output it is not humanly possible to see this taking place so it seems like a "blank screen popping out".

As far as I can see (from man lxterminal and from Google), there is no specific way to ask lxterminal to stay open after it has executed a script, so you have to change the bash script (i.e. your hello.sh) itself.

For example you could add either of the following to the end of your script.

  1. echo "Press [ENTER] to exit" && read

    • The terminal will wait for the user to hit Enter. (In fact to type anything followed by Enter.)
  2. /bin/bash

    • The terminal will stay open.

For a discussion of the general problem of stopping the shell from closing after executing a command, including information about other terminal emulators, see: How to run a script without closing the terminal?

By the way the semicolon at the end of the Desktop file doesn't do anything, so you might as well remove it.

Summary: The only change you need to make to your original desktop file is Terminal=false, but you need to add a line to the end of your bash script if you want to see that the script has run.

wjandrea
  • 14,504