Today I wanted to create a desktop entry (shortcut) for my Eclipse installation. I had to create the file “/usr/share/applications/eclipse.desktop” which is located in a system directory, so I needed privileges to create such file. Since I came from Ubuntu the first thing I tried was to run the command “sudo gedit” which throwed me the error:
(gedit:9901): Gtk-WARNING **: cannot open display:
I assumed it was due to the fact that another user (root) can not access my display, so I’ve tried the command “gksudo gedit” which, to my surprise, doesn’t exist on OpenSUSE. The last thing I tried before heading to the internet was changing to root with the command “su” and then running gedit which, again throwed an error:
GLib-GIO:ERROR:gdbusconnection.c:2279:initable_init: assertion failed: (connection->initialization_error == NULL)
I was almost giving me up until I found this thread. In openSUSE you should use xdg-su instead of gksudo.
So, finally the command I ran was
xdg-su -c gedit
this worked for me!
Note: I discovered recently that you could run “gnomesu gedit” which, I think, is more easy to remember