1

Opening the apps such as Gedit or Gnome Text Editor with sudo in Terminal, will open the app with default preferences and furthermore it won’t let me change those settings; however as an administrative user I have changed various preferences that seem to be ignored.

Here’s a screenshot for comparison: root vs. user

user preferences ignored using root

When trying to change the preferences after opening the app with sudo, I get the following error/warning in Terminal (in which tedit is a symbolic link to gnome-text-editor):

(tedit:37067): dconf-WARNING **: 11:36:56.149: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=cca92021290f49f5b00d396a

So, is there a way to change preferences for root to be followed when opening the app with root privileges?

I tried the following with no success:

  1. Logging in as root with su root and then opening the app;
  2. Opning the app using gksu;
  3. Editing the default parameters of gsettings schema for the specific app in /usr/share/glib-2.0/schemas/org.gnome.TextEditor.gschema.xml;
  4. Opening the directory /usr/share/applications as administrator and then launch the app using .desktop files.

Edit 1

I just found out the option sudo -E as a workaround to open a file with root but in my user environment, for examle:

sudo -E gnome-text-editor [path-to-file]

But I’m still eager to know if there’s a straightforward method to change root preferences permanently.


Edit 2

I found out accidentally that the foremenitoned method (3), i.e. changing schema’s default values, does work but you need to recompile them with:

sudo glib-compile-schemas /usr/share/glib-2.0/schemas/

Yet I consider this as another workaround, not a real answer.

1 Answer 1

1

Depends on the settings... In this case (gedit preferences) the settings are normally stored in a binary file via dconf (in the respective user's XDG_CONFIG_HOME). However, since dconf doesn't have access to a DBUS_SESSION_BUS_ADDRES when you invoke gedit with sudo (that's why you get those warning messages), it doesn't work. People usually try to work around by getting the address, exporting it etc
I think the most straightforward way is via dbus-run-session e.g. to set the gedit color scheme to solarized dark for the root you could run:

sudo -i -u root sh -c 'exec dbus-run-session -- gsettings set org.gnome.gedit.preferences.editor scheme "solarized-dark"'

or, open directly gedit

sudo -i -u root sh -c 'exec dbus-run-session -- gedit'

and customize as you wish, the settings will be saved for the next time you run sudo gedit.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .