[SOLVED] Change menu highlight color to a specific color? XFCE

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
begtognen
Level 3
Level 3
Posts: 100
Joined: Mon Aug 29, 2016 4:33 am

[SOLVED] Change menu highlight color to a specific color? XFCE

Post by begtognen »

OS: Linux Mint 21 XFCE

I'd like to change the menu highlight color to a specific color (not change theme or style). This is the color behind a chosen menu item.

I'm not sure, but maybe it has something to do with selected_bg_color? If it does, where do I change that?

Thanks for any ideas/suggestions.
Last edited by begtognen on Mon Dec 04, 2023 6:38 pm, edited 1 time in total.
michael-hi
Level 4
Level 4
Posts: 282
Joined: Sun Mar 19, 2017 2:31 pm

Re: Change menu highlight color to a specific color? XFCE

Post by michael-hi »

Hello begtognen,

You can override individual aspects of your GTK theme by adding text such as the examples shown below to a file inside your home folder, specifically to the file ~/.config/gtk-3.0/gtk.css

First though check in Thunar's View menu that Thunar is set to show hidden files (those beginning with a dot) and then create that gtk.css file if it does not already exist.

Note there are two things - the menubar (which is horizontal) and the menu (the drop-down part). What I have included in my own gtk.css override file is the following:

Code: Select all

/* Selected menubar and menu items */
menubar > menuitem:hover {
    color: #ffffff;
    background-color: #3fc763;
    box-shadow: none;
}
menu > menuitem:hover {
    background-color: #3fc763;
}
If you only want to change the menu part, then obviously just use the second part of the above code, starting at menu. The colour #3fc763 is a shade of green so simply change that to what you want. For the menubar part you could alternatively do something like this to colour the text and underlining instead:

Code: Select all

menubar > menuitem:hover {
    color: #3fc763;
    box-shadow: inset 0 -3px #3fc763;
}
Finally, if you want to change the general background colour of all the (unselected) menu items you could also add something like:

Code: Select all

menubar, menu {
    background-color: #ccffcc;
}
I can't remember for certain but you may need to log out and back in again for all these to work. Good luck! :)
begtognen
Level 3
Level 3
Posts: 100
Joined: Mon Aug 29, 2016 4:33 am

Re: Change menu highlight color to a specific color? XFCE

Post by begtognen »

This worked perfectly, thank you.

And as a follow up, any chance you know what the term is for the color that highlights what's selected in the window? Like the email message in Claws Mail or the file in Thunar?
michael-hi
Level 4
Level 4
Posts: 282
Joined: Sun Mar 19, 2017 2:31 pm

Re: Change menu highlight color to a specific color? XFCE

Post by michael-hi »

Not sure about Claws Mail but I think .view:selected would highlight things like the selected file in Thunar, so:

Code: Select all

.view:selected {
   background-color: #3fc763;
}
Other selectors you could try for similar highlighted things might (for instance) include:

Code: Select all

row:selected, treeview:selected, calendar:selected, text selection, entry selection, spinbutton selection, label selection {
    background-color: #3fc763;
}
Hope this helps...
begtognen
Level 3
Level 3
Posts: 100
Joined: Mon Aug 29, 2016 4:33 am

Re: Change menu highlight color to a specific color? XFCE

Post by begtognen »

Thanks so much, this worked a treat for Thunar. It didn't work for Claws Email, but I think it's drawing from the theme, so I'm going go muck around in theme settings and see if I can fix that.
michael-hi
Level 4
Level 4
Posts: 282
Joined: Sun Mar 19, 2017 2:31 pm

Re: Change menu highlight color to a specific color? XFCE

Post by michael-hi »

begtognen wrote: Thu Nov 30, 2023 3:23 pm It didn't work for Claws Email, but I think it's drawing from the theme, so I'm going go muck around in theme settings and see if I can fix that.
I haven't used Claws Mail before but, looking at it now, the highlighting colour does seem to come from the GTK theme as you say. You could change it by adding the following to your file at ~/.config/gtk-3.0/gtk.css

Code: Select all

.gtkstyle-fallback:selected {
    background-color: #3fc763;
}
Admittedly, this might possibly affect other things as well. The only thing I'm aware of is that it might also change the colour of your window titlebars, which is what I mostly use it for! If that applies in your case, hopefully you will be able to resolve it by finding a particular colour that works for both - or by choosing a different window manager theme. :)
begtognen
Level 3
Level 3
Posts: 100
Joined: Mon Aug 29, 2016 4:33 am

Re: Change menu highlight color to a specific color? XFCE

Post by begtognen »

You're absolutely right, this worked beautifully. Thank you.
Post Reply

Return to “Xfce”