How do I get a matching theme when I run a program as root?

I use a Metacity theme in my Ubuntu installation. Unfortunately, it isn't activated for programs with GUI that are started as root user and some other other certain programs like gufw. When I start gufw by command-line not as root, it uses an old, not very attractive theme.

For example, gufw gives the following output from the command-line:

/usr/share/themes/Finery/gtk-2.0/gtkrc:365: error: unexpected number `0', expected number (float)
/usr/share/themes/Finery/gtk-2.0/gtkrc:365: error: unexpected number `0', expected number (float)

What could be the reason for this issue? Is there a way to enable this theme for these other programs?


Themes you install via GNOME Appearance Settings reside in ~/.themes - your own home directory, where root won't be looking for them. You'll notice that themes that are installed system-wide (like ambiance/radiance) work fine, since those live in /usr/share/themes

To fix the issue, open your terminal and type

sudo ln -s ~/.themes /root/.themes

That way, root and your normal user will share the theme directory and everything will look the same.


Do a

$ sudo ln -s ~/.themes /root

This symlinks your theme directory so it can be used by the superuser account. Now any application run as root (or sudo/gksudo) will use your selected theme.


Found a solution.

  1. Open HOME folder
  2. Show hidden files
  3. Make a link for the .theme folder
  4. Open Nautilus as root - ALT + F2 then enter GKSU NAUTILUS
  5. Navigate to Root Home folder
  6. Show hidden files
  7. Move link to .theme folder into Root Home folder
  8. Rename folder to .theme

close Root Nautilus and re-open

Or

Open terminal:

sudo ln -s ~/.fonts /root/.fonts  

sudo ln -s ~/.icons /root/.icons

sudo ln -s ~/.themes /root/.themes