4

In the old days, all X11 applications would take standard command-line arguments to specify things like foreground/background color. Is there a way to do that today for GTK applications? In particular I'm interested in controlling the colors of zenity dialogs.

I use Xfce with Fedora 20, if that matters.

If it can't be done on command line, I'm open to hearing about alternatives. I don't know how to do this at all (even though command line would be preferable).

BobDoolittle
  • 1,607
  • 15
  • 26

2 Answers2

2

This is WRT Gtk 2.0, although I presume 3.0 is similar (and Xfce uses 2.0 anyway, I think).

Themes, etc. are defined using configuration files. The default one is ~/.gtkrc-2.0, but it can be overridden using an environment variable:

GTK2_RC_FILES=~/.gtk2-altrc xfce4-terminal

Will start the Xfce terminal using ~/.gtk2-altrc. The easiest way to generate these is probably first to back up your existing .gtkrc-2.0 file, then run gtk-chtheme (you may need to yum install gtk-chtheme). Pick your style, font, etc., click "Apply" and exit. That changes ~/.gtkrc-2.0, so you can now copy that to .gtk2-altrc, and replace it with the backup of the original.

I don't do this regularly myself, and can't guarantee it will work with everything (I don't use zenity either), but it is simple enough to try.

goldilocks
  • 86,451
  • 30
  • 200
  • 258
  • Sadly not working for me. When I ran gtk-chtheme, it resulted in a simple .gtkrc-2.0 file that included a standard theme I had selected for my desktop (Adwaita). So I copied down that file to .gtkrc-zenity, and tried your trick above. No matter how I edit the colors in my .gtkrc-zenity file, there is no effect on zenity's appearance. I didn't have a .gtkrc-2.0 file initially, so I've deleted it again just in case. No change. For reference I've saved my customized theme config file here: http://pastebin.com/8iGvc66G I also tried applying that to xfce4-terminal, and similarly no effect. – BobDoolittle Jul 10 '14 at 16:22
  • Does it work with `Terminal`? If so, then this is a dead end. If not, it should, so perhaps you've done something to screw up the config file. – goldilocks Jul 10 '14 at 16:26
  • I don't have anything called Terminal. I tried xfce4-terminal which is the Xfce equiv. No dice. – BobDoolittle Jul 10 '14 at 16:28
  • Here's what I changed, relative to the original /usr/share/themes/Adwaita/gtk-2.0/gtkrc (which was being included for my .gtkrc-2.0 after gtk-chtheme): http://pastebin.com/SeuCgDa9 Very simple – BobDoolittle Jul 10 '14 at 16:32
  • `Terminal` and `xfce4-terminal` are actually the same thing; the former was the original name, and (all apologies) I evidently added a symlink here rather than edit old scripts. Anyway, it works for me (fedora 20 KDE) so it should also work for you. Work in steps rather than jumping to the end, i.e., **don't manually edit anything yet**. Chose an alternate theme, save with "Apply" and use as above. That should work w/ `xfce4-terminal`. Once you've got that straight, try it with zenity. If that works, you know it's your manual edit -- the problem may or may not... – goldilocks Jul 10 '14 at 16:37
  • ...show up as an explicit error. Since Xfce is Gtk based whereas KDE is not, there's a chance the former is interfering. But again: to test the premise, use a file created by `gtk-chtheme` without editing it. If that works out, tinker further. – goldilocks Jul 10 '14 at 16:39
  • Good advice. I'll try it in a bit. It's a shame that gtk-chtheme can't write out its result without affecting my desktop theme as a whole. That requires some resetting in order to perform the experiment. – BobDoolittle Jul 10 '14 at 16:57
1

zenity is part of GNOME and the default package surely uses GTK+3.

xfce4-terminal on the other hand still uses GTK+2 and what posted by @goldilocks should work (you need to quit all instances of xfce4-terminal to be sure the new RC is picked up).

For changing GTK+3 themes you should edit or create $XDG_CONFIG_HOME/gtk-3.0/gtk.css (usually $HOME/.config/gtk-3.0/gtk.css). Here is a basic introduction to the CSS theming from the GTK+ team and the following fake gtk.css will help you to get started:

.notebook {
    -GtkNotebook-initial-gap: 20;
    -GtkNotebook-arrow-spacing: 20;
}
.notebook.arrow {
    color: black;
}
.notebook.arrow:prelight {
    color: white
}
.notebook.arrow:insensitive {
    color: gray
}
GtkLabel {
    text-shadow: none;
}
GtkEntry {
    padding-left: 10px
}
GtkSearchEntry, GtkSearchBar GtkEntry {
    padding-left: 0px
}
ntd
  • 346
  • 3
  • 12