how to get a desktop "luncher" icon that runs a specified program in lxterminal??

Please post all general support questions for LXDE here.
Locked
knott
Posts: 2
Joined: Fri Nov 10, 2017 10:50 pm

how to get a desktop "luncher" icon that runs a specified program in lxterminal??

Post by knott »

I am trying to create a shortcut (launcher) icon on my desktop in LXDE
that, when it is double-clicked will (1) run a terminal
window, (I require LXTerminal with a white background),
and (2) execute the command specified in my shortcut
desktop file which is: /usr/local/lib/mlab/mlab (This
should run the specified executable mlab in the Terminal
window that has been started in step (1).


1. I used google to find a way to create
a "shortcut" (aka "launcher") icon on my LXDE desktop, including
visiting lxde forum links.
There were several confusing and incomplete
posts, none of which dealt with this exact issue (a desktop icon
for launching an executable in a Terminal window).
[I have played around with many permutations with no success.]


2. I clicked in the "background" to get a menu, and selected "Create
new", this offered a sub-menu; I choose "empty file" I was prompted for
the filename, and I entered mlabt1

This created an "page-of-lines" icon on the desktop labeled
"mlabt1"

3. I right-clicked on this new mlabt1 icon, and selected properties in
the pop-up menu. The information window that appeared said this icon
corresponds to an empty file in ~/Desktop/ with permissions 334.
I changed these permissions to 775.

4. I inserted the following text into this file: (suggested by web-posts)

[Desktop Entry]
Name=mlabt1
Type=Application
Exec=sh /usr/local/lib/mlab/mlab
Terminal=true
Path=/home/knott
GenericName=MLAB
X-KeepTerminal=true

The mlabt1 icon changed immediately to a "gear".

[In fact, it is unneccessary to go through click create new, properties,
etc. All one needs to do is create a file in ~/Desktop with the
(hopefully) appropriate content using emacs or any other editor.]


5. I double-clicked on the mlabt1 icon and a proper LXterminal window
pops-up!! BUT the mlab program specified in the Exec-line
was NOT run! There is a bash prompt in the terminal window, and
if I type "mlab", the program runs.


6. I edited the file ~/Desktop/mlabti to change the
Exec-line to: Exec=/usr/local/lib/mlab/mlab and double-clicked to try to
run mlab. No joy. The terminal window popped-up with a bash prompt
as before!

7. So what's missing?

There seem to be at least three places where such "shortcut files go.

~/Desktop/

~/.local/share/applications/

/usr/share/applications/


I copied mlabt1 into ~/.local/share/applications/ -- nothing
new appeared. I rebooted. Still no presence of mlabt1 from
the /local/share/applications directory.

8. So what am I doing wrong? [And by the way, is there a document that
describes the LXDE "desktop" program and all the files it uses, whate
tey are for, and where they live, etc.??]

Is being able to get a shortcut to run a program in a
new terminal window impossible? Is this a bug?

In the file below, I take Name=mlabt1 to mean specifiying the label on
the icon appearing in the Desktop. I take Path=/home/knott to
specify my working directory (and indeed, that is what pwd in the
new terminal window shows). I have no idea what GenericName=MLAB and
X-KeepTerminal=true really mean.



[Desktop Entry]
Name=mlabt1
Type=Application
Exec=/usr/local/lib/mlab/mlab
Terminal=true
Path=/home/knott
GenericName=MLAB
X-KeepTerminal=true

So where should I put a launcher file, and what should be in it??
Does it need a special name? By the way there is a
permissions tab on the properties window for an icon, I changed the
appropriate enties to 'Anyone'. It made no difference.]

I need step-by-step instructions if anyone has them>

Thanks, garyknott@gmail.com
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: how to get a desktop "luncher" icon that runs a specified program in lxterminal??

Post by seppalta »

I am confused by your account of your activities and their relationship to get a desktop launcher. First, does your mlab launch when you type /usr/local/lib/mlab/mlab, or sudo /usr/local/lib/mlab/mlab into the terminal and press enter? The install for mlab that I managed to find said the command to launch was /usr/local/lib/mlab/??

Once you have determined (tested positively) the command for launching mlab, there are standard procedures for setting up desktop, panel or menu launchers in Openbox (LXDE). I suggest you take a look at the following links:
http://lxlinux.com/#2 ,
http://lxlinux.com/#6 ,
http://lxlinux.com/uxlta.html .
knott
Posts: 2
Joined: Fri Nov 10, 2017 10:50 pm

Re: how to get a desktop "launcher" icon that runs a specified program in lxterminal??

Post by knott »

Dear sepalta, I mean exactly what I said: /usr/local/bin/mlab (- not usr/local/lib/mlab)
is just a script to run /usr/local/lib/mlab/mlab which runs fine when I type it
in a terminal window.

Anyway, I'm afraid I cannot understand what the link you cited is trying
to tell me. It doesn't seem to cover my case, it doesn't contain definitions of terms, and
it isn't a real "manual". Can you or another reader tell me:


(1) WHERE I should my "launcher" file? I have it in /home/knott/Desktop/
and it is assigned 775 protection code and named mlabt1 associated
with an icon on my desktop. When I look at "properties" of that icon,
the reporting window says:

command: /sh /usr/local/lib/mlab/mlab
"execute in terminal window" checked.
"keep terminal window open after command execution" checked.
working directory: /home/knott
tooltip: blank

This does not work, as described above, and it doesn't work if the sh
is dropped.

(2) Tell me exactly what my "launcher" file should contain?
Currently it contains:
[Desktop Entry]
Name=mlabt1
Type=Application
Exec=/usr/local/lib/mlab/mlab
Terminal=true
Path=/home/knott
GenericName=MLAB
X-KeepTerminal=false

Thanks, garyknott@gmail.com
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: how to get a desktop "luncher" icon that runs a specified program in lxterminal??

Post by seppalta »

In the default lxde desktop, pcmanfm is in charge of the desktop. I presume you have not altered this, because if you did, then putting a desktop file in ~/Desktop does nothing. See the discussion in Section 2 of my first reference.

The general nature of .desktop files in discussed in Section 6 of lxlinux, the first reference that I gave you. There are several types and they are used for a variety of tasks. Your launcher desktop file, appropriately completed, only needs the following:

Code: Select all

[Desktop Entry]
Type=Application
Name=mlabt1
Exec=
Icon=[path to icon that you want]
Terminal=[false, true]
Name it mlabt1.desktop. Put it in ~/Desktop. Make it executable: sudo chmod 755 ~/Desktop/mlabt1.desktop. Complete the icon entry and put Terminal=false for the first round of "exec" choices. If none of those works, then retry with Terminal=true.

The main job is getting an "exec" that works. This depends upon the nature of the mlab exec script. If you do not know what it is, then you are left with guessing. Since you said "/usr/local/bin/mlab" launches it from terminal, I would start with just that command: Exec=/usr/local/bin/mlab, or just Exec=mlab since normally /usr/local/bin is "on the path".

If that doesn't work, then try the following in order:
lxterminal -e bash -c '/usr/local/bin/mlab;exec bash'
lxterminal -e bash -c '/usr/local/bin/mlab;$ SHELL'
lxterminal -e ~/bin/tlaunch.sh "/usr/local/bin/"
Here "tlaunch.sh" is defined in the references that I gave you. These all do the same thing, so they will likely all work or not work, but it makes you feel better to have more to try!

Finally, you can simply construct a shell script that uses xdotool to mimic your actions that successfully launched the application when you directly used the terminal. Name it mlab.sh, put it in ~/bin, make it executable and use exec=~/bin/mlab.sh. Use ispell.sh, or shutdown.sh if you used root terminal, from my third reference to be the template for mlab.sh. Edit the template so that xdotool key type "/usr/local/bin/mlab" &, and your password replaces password.
Locked