Set a specific theme for root launched applications

You are right when you found out that applications launched as root adopt the theme of the user that invokes them.

However there are few applications only that make sense to be launched as root. Fortunately for me these are three applications only:

  • Gedit
  • Nautilus
  • Terminal

All these three applications can at least partly be themed independent of the desktop theme. Once they are issued as root changes to the theme can be applied and will be kept:

enter image description here

Left: default themes | right: root themes


I found a hack to get get a system wide change :)

  • From the Appearance Preferences choose a theme you have installed in ~/.themes
  • Make a .themes folder in /root :

sudo mkdir /root/.themes

  • Copy your theme to /root/.themes :

sudo cp -r ~/.themes/yourTheme /root/.themes

  • Delete the gtk-2.0 and metacity-1 folders in /root/.themes/yourTheme :

sudo rm -R /root/.themes/yourTheme/gtk-2.0 /root/.themes/yourTheme/metacity-1

  • Copy the gtk-2.0 and metacity-1 folders of the new root theme to /root/.themes :

sudo cp -r /PathToRootTheme/gtk-2.0 /root/.themes/yourTheme/ ; sudo cp -r /PathToRootTheme/metacity-1 /root/.themes/yourTheme/


I used a different approach. I use per-user themes and icons for the normal user. These are at ~/.themes and ~/.icons. My methods involve tricking the root apps into thinking that they're using current user's local theme,but in fact uses another global theme.

Method 1 : Using a systemwide/global theme and icons for Root Apps

Step 1 : Create symlinks in /root/.themes and /root/.icons to the global theme and icon you wish to use for root apps. Make /root/.themes and /root/.icons folders if they don't exist already:

sudo mkdir /root/.themes
sudo mkdir /root/.icons

I use the default Ubuntu Theme(Ambiance) and Icons(ubuntu-mono-dark).Replace Ambiance and ubuntu-mono-dark with the theme and icons you wish to use, and run the following commands:

sudo ln -s -t /root/.themes /usr/share/themes/Ambiance
sudo ln -s -t /root/.icons /usr/share/icons/ubuntu-mono-dark

But make sure that the theme and icon are available at /usr/share/themes and /usr/share/icons,or else Root Apps won't be able to access them and they'll look ugly.

Note: The previous answers involved copying the entire theme and icon folders to /root/.themes and /root/.icons. A similar approach is used in Method 2 of this answer. But,i prefer symlinks as they avoid data duplication and gets the job done.

Step 2 : Rename the theme and icon symlinks in /root/.themes and /root/.icons to exactly the same name as the one from ~/.themes and ~/.icons that you're currently using. As i'm using Delorean Dark theme and Faenza-Darkest icons,the commands in my case would be:

sudo mv /root/.themes/Ambiance '/root/.themes/Delorean Dark'
sudo mv /root/.icons/ubuntu-mono-dark '/root/.icons/Faenza-Darkest'

Replace Delorean Dark and Faenza-Darkest with the names of the themes you use.

Shortcut Command: You may perform Step 1 and 2 in 1 step

sudo ln -s /usr/share/themes/Ambiance '/root/.themes/Delorean Dark'
sudo ln -s /usr/share/icons/ubuntu-mono-dark '/root/.icons/Faenza-Darkest'

Method 2 : Theme and Icons exclusively for Root Apps

If you wish to make Root App themes and icons not accessible to normal users,don't place them in /usr/share/themes and /usr/share/icons. Instead, place them in /root/.themes and /root/.icons. Then rename them to the same name as your current theme and icons, similar to Step 2 of Method 1.


There is more simpler solution.

Go to one of the tty's (by clicking on Ctrl+Alt+F3 or Ctrl+Alt+F4 or Ctrl+Alt+F5 for example). Login as 'root'. type :

startx

Now you are logged as root into graphical mode, search the 'tweak' application and check the dark mode, logout. After you are back to the tty command line type:

exit.

To return to your session try clicking (Ctrl+Alt+F1 or Ctrl+Alt+F7)