SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-05-09 14:58:44

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

[SOLVED]Command to refresh GTK theme?

I'm working on a script to save/restore OB and GTK theme configs, and although it is working OK, I can't find how to refresh the GTK theme with a command. Usually you would select and apply it with lxappearance, but how to do it without the gui?

The relevant gtk config files are in place (I think!), and the OB theme changes OK, but the gtk theme doesn't refresh.

"openbox --reconfigure/--restart" isn't doing it, and I don't want to use the gui or logout/login.

Any suggestions?

Last edited by damo (2015-05-09 16:27:57)

Offline

Help fund CrunchBang, donate to the project!

#2 2015-05-09 15:23:58

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: [SOLVED]Command to refresh GTK theme?

Never found anything.  After some research, I wrote this for waldorf/wheezy using python 2 (2.7).  Untested in jessie or with python3:

#!/usr/bin/python
#  gtkreload

def usage():
    print """\
Usage: gtkreload
  Signal applications to reload gtk, usually to apply a new theme."""
    exit()

import sys, gtk

if len(sys.argv) >= 2:
    usage()
events=gtk.gdk.Event(gtk.gdk.CLIENT_EVENT)
data=gtk.gdk.atom_intern("_GTK_READ_RCFILES", False)
events.data_format=8
events.send_event=True
events.message_type=data
events.send_clientmessage_toall()

Call it "gtkreload", add execute permission, shebang invokes python interpreter.

Last edited by cpoakes (2015-05-09 15:26:32)


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#3 2015-05-09 15:53:12

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: [SOLVED]Command to refresh GTK theme?

Thanks cp smile   Glad to know it isn't just me being thick!

I'll play with that code, thanks

EDIT: Works a treat!!  kiss

Last edited by damo (2015-05-09 16:07:58)

Offline

#4 2015-05-09 16:27:37

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: [SOLVED]Command to refresh GTK theme?

Using @cpoakes python code in a function within a bash script - it does the job smile

function reloadGTK(){
python - <<END
import sys, gtk

if len(sys.argv) >= 2:
    usage()
events=gtk.gdk.Event(gtk.gdk.CLIENT_EVENT)
data=gtk.gdk.atom_intern("_GTK_READ_RCFILES", False)
events.data_format=8
events.send_event=True
events.message_type=data
events.send_clientmessage_toall()
    
END
}

Offline

#5 2015-05-09 18:00:09

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: [SOLVED]Command to refresh GTK theme?

Nice adaptation to the shell.  Doesn't need the "sys" import or the "if..usage()" lines:

function reloadGTK(){
python - <<END
import gtk

events=gtk.gdk.Event(gtk.gdk.CLIENT_EVENT)
data=gtk.gdk.atom_intern("_GTK_READ_RCFILES", False)
events.data_format=8
events.send_event=True
events.message_type=data
events.send_clientmessage_toall()

END
}

programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#6 2015-05-09 19:04:18

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: [SOLVED]Command to refresh GTK theme?

Thanks smile

Offline

#7 2015-05-10 00:59:25

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: [SOLVED]Command to refresh GTK theme?

    $ aptitude show filename
Package: gtk-theme-switch         
State: not installed
Version: 2.1.0-2
Priority: optional
Section: x11
Maintainer: Denis Briand <denis@narcan.fr>
Architecture: amd64
Uncompressed Size: 111 k
Depends: libatk1.0-0 (>= 1.20.0), libc6 (>= 2.2.5), libcairo2 (>= 1.2.4), libfontconfig1 (>= 2.8.0),
         libfreetype6 (>= 2.2.1), libglib2.0-0 (>= 2.16.0), libgtk2.0-0 (>= 2.8.0), libpango1.0-0 (>= 1.14.0)
Conflicts: gtk-theme-switch
Description: GTK+ theme switching utility
 Utilities to easily switch GTK+ themes that can be run from the console, and has an optional GUI dock and theme
 preview. It can install themes downloaded from gtk.themes.org as well straight from the tarball.
Homepage: http://gna.org/projects/gtk-theme-switch/

Last edited by Sector11 (2015-05-10 13:39:53)

Offline

#8 2015-05-10 03:11:22

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: [SOLVED]Command to refresh GTK theme?

Last edited by cpoakes (2015-05-10 03:29:15)


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#9 2015-05-10 13:42:46

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: [SOLVED]Command to refresh GTK theme?

Thank you cpoakes - sometimes things are not what they appear to be.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo