Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-02-27 13:45:20

abalfoort
Member
Registered: 2023-02-27
Posts: 4

[Solved] Different theme for sudo applications

I'm the maintainer of SolydX (Debian based distro with Xfce4) and I'd like to use a different theme for those applications that need root permissions. The user will have a clear, visual indication that these applications may harm their systems.

So, for example, if you run Gparted, the theme colors would be different from Mousepad.

I have adapted the Breeze theme for this and placed it in the root home directory:

/root/.local/share/themes/Breeze-Root

I adapted the gtk-3.0 ini file:

/root/.config/gtk-3.0/settings.ini

with this:

[Settings]
gtk-font-name=Clear Sans Regular 11
gtk-theme-name=Breeze-Root
gtk-icon-theme-name=evolvere-2
gtk-fallback-icon-theme=gnome
gtk-toolbar-style=GTK_TOOLBAR_ICONS
gtk-menu-images=0
gtk-button-images=0

This works on SolydK with KDE Plasma 5.20 (with the same adapted theme), but unfortunately not on Xfce4 4.18. The user's theme is always used.

When I set the theme in xsettings.xml with this:

sudo xfconf-query -c xsettings -p /Net/ThemeName -s Breeze-Root

The results are the same.

I also tried to move the themes to /root/.themes as I saw some posts mentioning it, but to no avail.

Is it possible to have a different theme for sudo applications?

Last edited by abalfoort (2023-02-28 15:04:40)

Offline

#2 2023-02-27 15:50:49

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [Solved] Different theme for sudo applications

Hello and welcome.

I think this might be a result of pkexec and the limited environment variables it passes. Although, I'm not sure how this works in KDE - maybe the result of a different authentication agent?

I'm able to get gparted to use a different theme via:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GTK_THEME=Greybird-dark gparted

...but this still doesn't affect the xfwm4 window control - there isn't a way to set it via an environment variable. However, if you force the window to use CSD, then you can get a consistent look:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GTK_CSD=1 GTK_THEME=Greybird-dark gparted

I can't get it to work using GTK3 theme directives or settings.ini.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-02-27 16:32:40

abalfoort
Member
Registered: 2023-02-27
Posts: 4

Re: [Solved] Different theme for sudo applications

Thanks for the welcome and the quick reply.

An alias in ~/.bash_aliases could be a workaround. I'll check that out and report back later.

Although, it is a workaround, I would prefer something more consistent with normal gtk3 configuration. But, as you mentioned, that doesn't seem to work for use with pkexec.

Last edited by abalfoort (2023-02-27 16:33:46)

Offline

#4 2023-02-27 18:58:28

abalfoort
Member
Registered: 2023-02-27
Posts: 4

Re: [Solved] Different theme for sudo applications

Writing an alias works only for user commands in terminal with pkexec.

Any application started from the start menu will not use the alias. So, that is not a solution.

Is there a way to set the env variables for pkexec globally on a system?

Offline

#5 2023-02-27 21:05:52

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [Solved] Different theme for sudo applications

abalfoort wrote:

Is there a way to set the env variables for pkexec globally on a system?

If my understanding of polkit/pkexec is correct, this is not allowed.


However, via testing, it looks like you can populate /root/.config/gtk-3.0/gtk.css with some CSS and it will take effect. For example:

.background * {background-color: blue; color: yellow}

...changes most of the background blue and text yellow. You might be able to tweak it this way. Note this will affect all root applications - but maybe this is what you want.

If Breeze-root is all in one gtk.css file, perhaps try copying that over to /root/.config/gtk-3.0/gtk.css?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2023-02-28 15:03:50

abalfoort
Member
Registered: 2023-02-27
Posts: 4

Re: [Solved] Different theme for sudo applications

That was exactly what I was looking for!

/root/.config/gtk-3.0/gtk.css

@define-color bg_color #ff0000;
@define-color fg_color #ffffff;

menubar,
menubar > menuitem,
notebook > header {
    color: @fg_color;
    background-color: @bg_color;
}

menubar menuitem:hover {
    background-color: shade(@bg_color, 0.80);
}

menubar menu > menuitem:hover {
    background-color: @bg_color;
}

toolbar {
    background-image: linear-gradient(to bottom,
                                      shade(@bg_color, 1.0),
                                      shade(@bg_color, 0.80)
                                      );
}

toolbar button:hover,
toolbar button:active,
toolbar button:checked,
toolbar button:focus,
toolbar entry,
toolbar radio,
toolbar check {
    border: 1px solid shade(@bg_color, 1.50);
}

toolbar button {
    color: @fg_color;
    background-color: shade(@bg_color, 0.80);
}

/* Synaptic's toolbar */
.primary-toolbar {
    background-image: linear-gradient(to bottom,
                                      shade(@bg_color, 1.0),
                                      shade(@bg_color, 0.80)
                                      );
}

/root/.config/gtk-3.0/settings.ini

[Settings]
gtk-font-name=Clear Sans Regular 10
gtk-theme-name=Breeze
gtk-icon-theme-name=evolvere-2-blue
gtk-fallback-icon-theme=breeze
gtk-cursor-theme-name=oxy-white
gtk-toolbar-style=GTK_TOOLBAR_ICONS
gtk-menu-images=1
gtk-button-images=1
gtk-primary-button-warps-slider=0

This will use the default Breeze theme but changes the menu bar, tool bar and (some application only have this) the tabs.

This works for both KDE and Xfce4.

Thanks for your help.

Last edited by abalfoort (2023-02-28 18:54:33)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.014 seconds, 8 queries executed - Memory usage: 546.94 KiB (Peak: 547.78 KiB) ]