How to make a program launchable from krunner or the application launcher?

I have Matlab installed, and the only way for me to open it is from the command line. I made a shortcut to launch it, but I would really like to be able to launch it from the application launcher or with krunner.

What would be the best way to do this?

Thanks

You should be able to run it with krunner just the same as from the command line.

For the application launcher, just right-click on the launcher’s icon and select “Edit menu entries…” and create an entry.

Sorry, I think I was a little unclear in my post. By only being able to launch it in the command line, I mean only being able to launch the executable file, ie. ./matlab in its respective folder. Typing matlab into krunner does not give me anything.

Again, create a menu entry yourself using the menu-editor.
You can specify the directory the program should run in as well there.

If there’s an entry in the menu, you will also be able to run that with krunner.

And of course use an absolute path and not a relative like ./
Relative to what is that when started from an icon? You are not in a shell, thus what is the “working directory”?

Again, create a menu entry yourself using the menu-editor.
You can specify the directory the program should run in as well there.

I am able to create a menu entry in the menu editor, however it only works if I use the Run in terminal feature which launches an unwanted konsole window (I get this same issue with my desktop shortcut which I was hoping to avoid). I am still unable to launch it from krunner.

https://forums.opensuse.org/images/buttons/viewpost-right.png](https://forums.opensuse.org/showthread.php?p=2647941#post2647941) And of course use an absolute path and not a relative like ./
Relative to what is that when started from an icon? You are not in a shell, thus what is the “working directory”?

I am using an absolute path, specifically /home/user/Programs/MATLAB/R2013a/bin/./matlab

You can specifically set the “working directory” for the entry in the menu editor as I said. That setting is on the “Advanced” tab btw.
Thus a relative path is actually possible.

You can even omit the “./” in that case I suppose.

Or just select the executable that should br run in the file dialog (click on the disk symbol)…

You can specifically set the “working directory” for the entry in the menu editor as I said. That setting is on the “Advanced” tab btw.
Thus a relative path is actually possible.

You can even omit the “./” in that case I suppose.

Or just select the executable to run in the file dialog…

Alright, so this is what I have tried in the menu editor.

The full path in the “Command option”, result = Matlab splash screen opens, but the program itself never launches.

work path set to /home/user/Programs/MATLAB/R2013a/bin/ and Command set to either matlab or ./matlab, result = nothing happens when launched (I saved my settings)

full path in Run in terminal, result = launches with konsole window, still no krunner

Well, that’s matlab’s “fault” then if it only can run inside a terminal window. I don’t know matlab good enough to tell you whether there’s a way around that.

You could make the konsole window start minimized or similar by creating a window rule, or try to use “kstart” to start it. (see “kstart --help” for more informations)

I am still unable to launch it from krunner.

You should.
Can you run other menu entries with krunner?
The corresponding runner jas to be enabled of course.

Maybe krunner is just not aware yet of your changes? Try to run “kbuildsycoca4 --noincremental” and/or logout/reboot.

I am using an absolute path, specifically /home/user/Programs/MATLAB/R2013a/bin/./matlab

In this case you definitely can omit the “./”… :wink:

PS: by googling for “run matlab without terminal window” I found this:

Try “matlab -desktop” to run without a terminal.

No idea if that will work though, that’s from 2007:
https://www.mathworks.com/matlabcentral/newsreader/view_thread/157234

Finally got it to work. The -desktop works in the command line and in my shortcut, however in the menu editor it failed, even when I used \ to escape the space.

What ended up working in the menu editor was to disable to command line, set the working path, and use kstart ./matlab -desktop as the Command.

Krunner works like expected when I logged off.

Thanks a lot!

You should of course not escape the space, nor use quotes or similar. In the menu editor you should do just the same as in your shortcut (it should even be possible to move the shortcut’s .desktop file to ~/.local/share/applications/ to make it appear in the menu).

Most existing menu entries pass arguments to the command, so it should work.
Just take a look at the LibreOffice entries, they have something like “libreoffice --base %U” as command.

What ended up working in the menu editor was to disable to command line, set the working path, and use kstart ./matlab -desktop as the Command.

OK, if it works that’s fine I suppose… :wink: