Gnome 3 main menu shortcut problem

Hello, before even working on an older problem, I have a new one. I installed Matlab 2015b on my OpenSuse Leap, but I cannot make a working shortcut in Main Menu. I boiled the problem down to using this script :

#!/bin/bash
cd /home/Wabbajack/MATLAB/R2015b/bin;
./matlab -desktop

This works great when I run it from the terminal as a normal user, but if I run it as root, it runs as if the option '-desktop' was not present (runs in terminal). This same behavior occurs when I try to run this script via created shortcut through the Gnome favorites. This makes me think that gnome runs the applications as root by default. How can I change this?

Gnome does not run applications as root by default.

I had some trouble with this a longggggggggg ass time ago. The issue was that matlab wants root privileges because it can create new directories.

I am not sure if there is a way around this, and I am not sure you really need to get around this.

Personally I just ran the program as root because I wanted it to be able to create the directories without any issues.

I just modified the script to run the damn thing as root without the need for passwords. http://askubuntu.com/questions/167847/how-to-run-bash-script-as-root-with-no-password

I would suggest to use gksu in front of ./matlab that actually should be the GUI version of sudo.

Why do you switch into the Matlab directory beforehand?

gksu "/home/Wabbajack/MATLAB/R2015b/bin/./matlab -desktop" should pretty much start it.

Well i have been digging around a little and I think the problem that it only runs in terminal under root is that I have to X display associated with the root account. The thing is that it runs great as non-root. I will just run it from terminal until I find a solution.

Might be because the X variable is not set (or however this is called) try using su - for starting the root session. But I would heavy suggest to NOT do this, why would you want that?

might be something similar but think google or someone else using gnome and shortcuts would know better than me.

Why does it need to run as root?

1 Like

It does not need to. Sorry, English is not my native language. It only seems to me that Gnome 3 runs it as root. When I run the script as a normal user through terminal, it opens matlab GUI and works great. If I run it as root, it opens in terminal instead running GUI. When I click on the icon created by me, it does not start the GUI, so I deduced that Gnome might run it as root. Anyway, I am starting to think the problem is elsewhere and has something to do with xrandr.

Well I just found this, look like somebody already made a launcher. I will try it once I return home.

So an update is in order. Today I installed the launcher and it didn't launch. Tried to edit it's settings with gedit. Did not help. Just out of desperation tried the bash script I posted here. It works... No idea what was wrong.