You are not logged in.

#1 2016-10-15 22:50:39

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

HowTo: set a custom GTK2 theme for an application

This came up on the Crunchbang forums, specifically about the highlight colour in the Nitrogen gui: [Solved] Nitrogen - selected colour border..

I find that my preferred theme makes it hard to identify the selected background, so here is a way to run Nitrogen (or any other GTK2 application) with its own theme settings.
Information from urukrama's weblog

Method 1

1) Copy the theme to '~/.themes' (which is a symlink to '~/.local/share/themes'), and rename it. In my case I did

cp -r /usr/share/themes/FlatSlate  ~/.themes/FlatSlate-nitro

2) Edit the theme and change "selected_bg_color" to your choice. There are several places this might appear, but in BL themes it should be on the first line of "<theme name>/gtk-2.0/gtkrc"

gtk-color-scheme    = "bg_color:#333A43\nselected_bg_color:#1E90FF\nbase_color:#333940" # Background, base.

3) The magic happens when you start the application in a terminal with

GTK2_RC_FILES=~/.themes/FlatSlate-nitro/gtk-2.0/gtkrc nitrogen

Either export this as an environment variable, or start via a one-liner script which can be run from the Run box or Menu:
"nitro.sh"

#!/bin/bash
GTK2_RC_FILES=~/.themes/FlatSlate-nitro/gtk-2.0/gtkrc nitrogen

or use this command in the OB Menu:

bash -c 'GTK2_RC_FILES=~/.themes/FlatSlate-nitro/gtk-2.0/gtkrc nitrogen'
Method 2

If you’d also like to set a custom icon theme and font for the application, create an empty file, for example in /home/USERNAME/.themes) and call it whatever you want (for example, custom.gtkrc). Then add the following to that file:

#To set the Gtk theme
include "/path/to/your/theme/gtkrc"

#To set the icon theme
gtk-icon-theme-name = "Adwaita"

#To set the font
style "Sans"
{
font_name = "Sans 8"
}
widget_class "*" style "Sans"
gtk-font-name = "Sans 8"

If you want to use this in a launcher, or the OB Menu, use

bash -c 'GTK2_RC_FILES=~/.themes/custom.gtkrc application-command'

Before and After:
nitrogen.jpg

...and no other applications are affected wink

Last edited by damo (2016-10-17 09:51:01)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#2 2016-10-17 02:32:11

ututo
Member
Registered: 2015-09-29
Posts: 326

Re: HowTo: set a custom GTK2 theme for an application

this is very interesting, damo. I wonder if it would be possible to set a custom openbox theme for an application as well


BunsenLabs on deviantArt
Don't touch my git!

Offline

#3 2016-10-17 09:51:34

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: HowTo: set a custom GTK2 theme for an application

Added another method to Post #1


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#4 2016-10-17 09:52:34

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: HowTo: set a custom GTK2 theme for an application

ututo wrote:

this is very interesting, damo. I wonder if it would be possible to set a custom openbox theme for an application as well

AFAICS the theme is set for the Openbox session, so it affect all applications running in that session.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#5 2016-10-17 17:22:56

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: HowTo: set a custom GTK2 theme for an application

ututo wrote:

I wonder if it would be possible to set a custom openbox theme for an application as well

it doesn't really make sense - because openbox manages ALL windows of a session, plus a few more other things.
unless the window manager itself supports it (and openbox doesn't), it's not possible at all.
What you CAN do is set up openbox to not show any borders or only minimal borders, per application.

Offline

#6 2016-10-18 00:48:19

ututo
Member
Registered: 2015-09-29
Posts: 326

Re: HowTo: set a custom GTK2 theme for an application

sorry, I didn't know. I've seen you can customize windows titles in some applications in KDE. I thought this could be done in openbox but, as you say it's not possible at all. The thing is that I use light gtk themes but my terminals... i like them black, like my coffee. I think I will follow your advice @ohnonot. I will undecorate and remove windows borders from my apps. Thanks!


BunsenLabs on deviantArt
Don't touch my git!

Offline

#7 2016-10-18 16:52:15

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: HowTo: set a custom GTK2 theme for an application

ututo wrote:

I think I will follow your advice @ohnonot. I will undecorate and remove windows borders from my apps.

http://openbox.org/wiki/Help:Applications
smile

Offline

Board footer

Powered by FluxBB