LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to load a GTK 2.x theme with a command line or shell script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-load-a-gtk-2-x-theme-with-a-command-line-or-shell-script-820573/)

QueenZ 07-18-2010 02:57 PM

How to load a GTK 2.x theme with a command line or shell script?
 
I would like to know how i can load a gtk theme with a terminal command line or with a shell script if possible.

Thanks!

dugan 07-18-2010 03:18 PM

Code:

ln -sf /path/to/theme/gtk-2.0/gtkrc ~/.gtkrc-2.0

arizonagroovejet 07-18-2010 03:32 PM

I'd go with this:

Code:

gconftool-2 --set /desktop/gnome/interface/gtk_theme --type string 'Clearlooks Brave Dark'

To find gconf keys for other stuff like the icon theme open gconf-editor and look under desktop > gnome > interface

QueenZ 07-18-2010 03:44 PM

arizonagroovejet, that means i have to have GNOME installed to use gconftool...

I didn't quite understood dugan's method.. doesn't that just install the theme?? not apply it.

arizonagroovejet 07-18-2010 03:47 PM

I assumed you were using GNOME and that by 'load a gtk theme' you meant set it as your current theme in GNOME. Evidently I was wrong.

What do you mean by 'load a gtk theme'?

I don't understand dugan's suggestion either.

QueenZ 07-18-2010 03:48 PM

i tried ln -sf /usr/share/themes/Clearlooks/gtk-2.0/gtkrc ~/.gtkrc-2.0 it didn't apply it

QueenZ 07-18-2010 03:50 PM

arizonagroovejet, there are other desktop environments out there that use GTK toolkit not just GNOME... so i need something that would work for all of them..

arizonagroovejet 07-18-2010 03:57 PM

So you're looking for a single command that will change the theme in any desktop environment that uses GTK? If so I think you're looking for something that doesn't exist. GNOME uses gnome-settings-daemon to change the theme currently in use. Other desktop environments will use something else.


Now I think about it I'm guessing dugan's suggestion might work if you log out and in again, but I've not tried.

QueenZ 07-18-2010 04:01 PM

hmm... i guess... by the way, when i change the theme like you described, the gtk theme changed except for the window borders (try it). why is that and how can i change them too?

dugan 07-18-2010 04:05 PM

Quote:

Originally Posted by QueenZ (Post 4037456)
I didn't quite understood dugan's method.. doesn't that just install the theme?? not apply it.

It applies the theme to all applications started afterwards.

It certainly does not install the theme.

Quote:

Originally Posted by QueenZ (Post 4037467)
arizonagroovejet, there are other desktop environments out there that use GTK toolkit not just GNOME... so i need something that would work for all of them..

Use a GTK theme switcher then. gtk-chtheme and LXAppearance are both good ones.

QueenZ 07-18-2010 04:09 PM

thanks for the clarifications dugan. gtk-chtheme sounds good.

did i use that command right?

Quote:

ln -sf /usr/share/themes/Clearlooks/gtk-2.0/gtkrc ~/.gtkrc-2.

dugan 07-18-2010 04:12 PM

Code:

ln -sf /path/to/theme/gtk-2.0/gtkrc ~/.gtkrc-2.0
Code:

ln -sf /usr/share/themes/Clearlooks/gtk-2.0/gtkrc ~/.gtkrc-2.
No, the trailing zero is important.

EDIT: A much more foolproof method would be to create a ~/.gtkrc-2.0 file with the following contents:

Code:

include "/path/to/theme/gtk-2.0/gtkrc"
When you start with the gtk theme switchers, you'll find that they work by doing a variation on the above.

QueenZ 08-06-2010 07:53 AM

ok, i tried doing this dugan but it didn't work... i did as you said and now my gtkrc-2.0 file contains this

Quote:

include "/usr/share/themes/Clearlooks/gtk-2.0/gtkrc"
but my theme has not changed. and applications that i start afterwards are still in the old theme. i tried logging out and back in and still Clearlooks is not my theme even if my gtkrc-2.0 file says so..

Quote:

queenz@martin-lucid:~$ ls -al
-rw-r--r-- 1 queenz queenz 53 2010-08-06 15:43 .gtkrc-2.0
I also made sure that /usr/share/themes/Clearlooks/gtk-2.0/gtkrc exists and it does but my theme is not changed still...

Please try it yourself and tell me if it works for you..

What am i doing wrong? :(

QueenZ 08-06-2010 08:07 AM

EDIT: It worked on my new Ubuntu which was just installed, i will see why it didn't work on my old ubuntu which has been used for some good time..

QueenZ 08-06-2010 08:14 AM

Oh i see what's happening, GNOME is forcing it's own theme on it and gtkrc-2.0 says another theme so it's like this GNOME tries to apply Ambiance and gtkrc-2.0 tries to apply Clearlooks lol...


All times are GMT -5. The time now is 02:15 PM.