0

Is there a way in Linux to set the desired icon sets and themes used when running apps as sudo. At the moment if I, for example, type ...

sudo gedit /et/fstab

Then if I click Save As then the file save dialog doesn't match my own desktop environment settings, it seems to use default icons and the default theme (Adwaita).

Is there anywhere this can be configured so that they match (or even better I'd like to make them largely the same but with different colours to indicate I'm running elevated).

I'm running Gnome on Manjaro if it's relevant.

I have tried a direct gsettings command line call:

sudo gsettings set org.gnome.desktop.interface icon-theme 'Tela-red-dark'

but that doesn't work, it did point me to look at doing my next thing which explained kind of why this didn't work.

I have tried running dconf-editor under sudo but that only offers limited options, excluding the desktop settings required to configure such things.

Is this an OS limitation or is there somewhere deeper down that I can configure the 'default' settings?

As I was interested, I also ran this...

sudo gsettings get org.gnome.desktop.interface icon-theme

To confuse my brain further, rather than returning Adwaita (which is what's used in the sudo run GUI windows) it returned Papirus-Dark-Maia which is the default icon theme that's used if you create a fresh new user in Manjaro.

LATER ON....

I logged on directly as root and set root up with the configuration that I want (similar to my main UI setup but with big glaring red danger colours) and that made no difference at all to what appears when sudo is used locally.

AND ALSO...

After being told that sudo shouldn't be used for such things I configured pkexec for my use case and enabled gedit following the instructions in this post: How do I run GUI applications as root by using pkexec?

I got exactly the same result as with using sudo from a UI perspective.

The elevated privilege apps seem to operate using their own default configurations for how to display which don't seem to honour the logged in user (which makes sense to me) or root which... doesn't.

My original question remains - How do I change the UI settings used by the elevated apps?

5
  • "Running apps as sudo" is a nonsense statement. You are using sudo to run a GUI application as root, which you shouldn't be doing. That said, whichever GUI toolkit this application uses, is taking its configuration from root, not from $USER. Obviously. Read unix.stackexchange.com/a/3071/420488 Aug 8, 2021 at 17:07
  • I've set up the desired configuration via root by logging in as root and logging out again but that doesn't pull through either. Aug 8, 2021 at 17:56
  • I'm relatively new to Linux but reading the Manjaro forums it looks like Arch and Manjaro have deprecated gksu - archived.forum.manjaro.org/t/gksu-has-been-deprecated/45610/4 for solething called PolicyKit. This happened in 2018 so before my time in Linux world. I just want to be able to edit a file... Aug 8, 2021 at 18:05
  • The replacement command is pkexec but that simply doesn't even work - Unable to init server: Could not connect: Connection refused (gedit:57304): Gtk-WARNING **: 19:07:35.405: cannot open display: In order to rectify this you need to configure the app to allow itself to execute - unix.stackexchange.com/questions/203136/… Aug 8, 2021 at 18:08
  • 1
    Looks like there's some good bits in the question you link. But... if whatever editor you want to use isn't well-mannered enough to ask for privs when it needs them and drop them when it doesn't, find a better editor. Aug 8, 2021 at 21:21

1 Answer 1

0

I resolved this in the end - with multiple tweaks along the way (all good).

Firstly I looked at using pkexec instead of sudo - That gives a nice GUI password prompt too, but until you configure it to allow your editor to run it doesn't work.

In order to use this, follow the instructions on this post: How do I run GUI applications as root by using pkexec? - once the settings file is created for gedit (or your GUI editor of choice) then all is well in pkexec world.

This doesn't fix the underlying issue though, which is the application of themes. In order to apply themes you have to do several things - miss any out and it doesn't work...

  1. Log out and log in as root
  2. Make sure that root has the same themes installed as your user account if you have themes installed in your user space.
  3. Set root theme setting to be like your own
  4. Reboot (this is crucial - a log out won't cut it)
  5. Log in again in your own account
  6. Run your editor with pkexec, gksu, sudo or whatever (makes no difference to the end result) - The UI will match your set up now.

This still left me with some odd unexpected behaviours. For example - I configured root to use the light version of the same GTK+ theme that I'm using on my account with an icon theme that had different coloured folders (So the root stuff would glare in bright red at me). While that applies when logged in as root that seems to be ignore on my account and `pkexec' (or whatever elevated run command you use) uses my own icon theme and colour. I still find this... odd - it seems that the GUI needs stuff to be installed for root but loads preferences based on your own account - I would have expected those preferences to be reflected by root but that doesn't seem to be the case.

Still looking to understand more about how the contexts interact at this point, but the initial problem is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.