$DISPLAY dependent gtk themes

2

I have a computer at home that I log into remotely. The "monitor" for it is a TV, so I want gtk applications to use a large font and icon theme, which I managed to do by editing the ~/.gtkrc-2.0 file and some other similar stuff. What I want to be able to do is have a separate theme for when I'm logging in remotely. The best way to explain is that I would like my gtk theme choice to be dependent on the X display that the application is started on. For example, if I start something on :0.0 then that is the TV and I want large fonts, but if I start it on localhost:10.0 I want to use a regular size font, because it will get rendered on my laptop screen.

The elegant solution would be to have some sort of IF statement in the .gtkrc-2.0 file that checks the $DISPLAY variable and behaves accordingly. The problem is I can't find any documentation on control structures in .gktrc files, or if it's even possible to do that.

[Edit] Additionally, is there any way to do this in GTK+ 3 without having to install gnome?

vlsd

Posted 2011-11-19T00:25:53.933

Reputation: 229

Answers

1

You can achieve this by running an XSETTINGS daemon, e.g. xsettingsd (or Xfce xfsettingsd or GNOME gsd-xsettings) locally on both machines. It will affect all clients of the X display it's running on, overriding gtkrc.

If the program uses GTK+ 2, you can point $GTK2_RC_FILES to a colon-separated list of alternative gtkrc's. (There is no direct alternative for GTK+ 3 settings.ini; it uses Xsettings as the primary mechanism.)

Note: This method will likely stop working in GTK 4, which prefers reading internal GSettings.

user1686

Posted 2011-11-19T00:25:53.933

Reputation: 283 655

Update: In recent GNOME versions, it might be more difficult to run g-s-d (now split off to gsd-xsettingsd`) without the rest of GNOME, however there are new alternatives available. – user1686 – 2019-11-03T18:31:17.737

I am pretty sure gnome-settings-daemon requires installing gnome, which is something I'm trying to avoid, as I want to keep a somewhat minimalistic setup. A google search for Xsettings daemon returns gnome-settings-daemon and basically nothing else. Is there a way to have this work for both GTK+ 2/3 without having to install the fullness of gnome? – vlsd – 2011-11-22T19:42:33.503

I am pretty sure it doesn't. I've used it with wmii myself. – user1686 – 2011-11-22T19:50:07.240

OK, I'll give it a try, I was probably reading the dependency list wrong. – vlsd – 2011-11-22T19:52:40.533

0

AFAIK it is not possible to make do any scripting for gtkrc. You can copy both configurations to somewhere where you can restore them from .xinitrc, .xsession or other X startup file. The only problem is that you can't use both :0.0 and :10.0 running in parallel with different themes. You should either run only one X at time or make different user with different home directory for your TV setup for instance. You can even use the same UID/GID for both users and will have access to all files.

Cougar

Posted 2011-11-19T00:25:53.933

Reputation: 533