Change Plasma Theme sudo/root applications use

I have noticed that whenever I happen to open a gui application with sudo that the system uses the default breeze plasma theme, I was wondering if there is anyway to change that? Is there a simple way to do this?

You can use konsave from the AUR to easily copy your theme from your user account to the root.

Just export a profile by name and then import it with sudo.

1 Like

I have no idea how to do that

Here is a post where I explained it for someone else

1 Like

I always seem to have problems with python apps on my last install, But this is a new clean install of endeavour os plasma

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 573, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 891, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 782, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (PyYAML 6.0 (/usr/lib/python3.10/site-packages), Requirement.parse('PyYaml==5.4.1'), {'Konsave'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/konsave", line 33, in <module>
    sys.exit(load_entry_point('Konsave==2.1.1', 'console_scripts', 'konsave')())
  File "/usr/bin/konsave", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/konsave/__init__.py", line 3, in <module>
    from pkg_resources import get_distribution, DistributionNotFound
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3266, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3240, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3278, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 575, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 588, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 777, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'PyYaml==5.4.1' distribution was not found and is required by Konsave

Is your system fully updated? Did you install it from the AUR?

installed from AUR, Fully up to date

Copy your local config files to /root/ (this is the relevant user folder for root/sudo user).
Depending on program’s toolkit, you need to copy (at least) these:

$HOME/.gtkrc-2.0
$HOME/.config/gtk-3.0/settings.ini
$HOME/.config/gtk-4.0/settings.ini
$HOME/.config/plasmarc
$HOME/.config/qt5ct/qt5ct.conf
$HOME/.config/Kvantum/kvantum.kvconfig

Important!
Make sure the settings do not include locally installed themes, only system themes (at /usr/share).

A good practice would be to set a different root theme than normal user’s, so it is immediately realized it has elevated privileges.

1 Like

We should not gloss over the fact that running ANY GUI application as root isn’t a good practice anyway.

From That Fine Manual:

https://wiki.archlinux.org/title/Running_GUI_applications_as_root

2 Likes

just posting to show some love for konsave. Awesome tool.

For that you can open system preferences as root, so you can modify the themes for when you use applications as root, although it is not convenient.
kdesu dbus-launch systemsettings5

What about using meld to pacdiff?
:smile:

I am not overly concerned, Just a personal computer not used for anything critical.

Thank you, that seems to do the trick, Also like the other solutions too, Wish Konsave worked for me but keeps spitting out errors. Not sure what the deal is with that. Anyway thanks for the help everyone.

1 Like

Funny how nobody noticed this here :grimacing:

Someone made a github issue and I am able to solve it. Just change the PyYaml version requirement and test it by running konsave -h.

Thanks, updated konsave and looks like it is now fixed.

Just login using root account and manually set the theme and color scheme, takes all of one minute, and all root gui apps (ie gparted) will look the way you wanted.

I prefer root gui apps to look slightly different, so I know I am running this as root, and know to be more careful.

No need to use konsave, keep your root profile as clean as possible, only change what is needed (ie theme, colors and .bashrc aliases).