You are not logged in.

#1 2010-08-15 02:52:58

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Openbox Theme from GTK theme [beta]

Something like this surely exists, here is my version..

Creates an Openbox Theme from your chosen GTK Theme ... ..in 1), 2), 3)...

1) you need to launch your theme changing from a script like this (instead of calling your GTK switcher directly)

#!/bin/bash
# call your gtk theme switcher and as it quits create a matching openbox theme
#
# command for gtk theme switcher
lxappearance
#
# path to auto openbox theme generator script
~/bin/auto-openbox-theme
#
# launch obconf (so you can select the newly made theme)
obconf
#
exit

2) For that to work you also need this next script in ~/bin/auto-openbox-theme and made executable

#!/bin/bash
# Looks for the current GTK theme and automatically creates a matching Openbox theme
#
# The script fails on themes not following the Clearlooks convention..
# ..future improvements will account for this - for now the script politely fails on such themes.
#
# function used to see if script is generating empty results from GTK it can't handle yet
function emptycheck {
    if [ -s $myfile ]
    then
        echo "$myfile has data."
    else
        echo "$myfile is empty."
        xmessage "Sorry this gtk is not handled yet. You should not select the generated Openbox Theme this time."
        exit
    fi
}
#
# main script #
#
# copy ~/.gtkrc-2.0 to a new file and remove all data except theme name line (!d = don't delete)
sed /gtk-theme-name/!d ~/.gtkrc-2.0 > ~/.gtk-match-openbox-info
#
# remove string before gtk theme name and return info to this file (-i)
sed -i s/gtk-theme-name=// ~/.gtk-match-openbox-info
#
# strip off all (/g) speach marks (\") and return info to this file (-i)
sed -i s/\"//g ~/.gtk-match-openbox-info
#
# place the theme name in a variable
mygtktheme=$(cat ~/.gtk-match-openbox-info)
#
# copy file called mygtktheme to a new file
sed /gtk_color_scheme/!d ~/.themes/"$mygtktheme"/gtk-2.0/gtkrc > ~/.gtk-match-openbox-info
#
# strip the line down to just colours
sed -i s/gtk_color_scheme\ =\ \"// ~/.gtk-match-openbox-info
sed -i s/gtk-color-scheme\ =\ \"// ~/.gtk-match-openbox-info
sed -i s/fg_color\:#// ~/.gtk-match-openbox-info
sed -i s/bg_color\:#// ~/.gtk-match-openbox-info
sed -i s/base_color\:#// ~/.gtk-match-openbox-info
sed -i s/text_color\:#// ~/.gtk-match-openbox-info
sed -i s/selected_bg_color\:#// ~/.gtk-match-openbox-info
sed -i s/selected_fg_color\:#// ~/.gtk-match-openbox-info
sed -i s/tooltip_bg_color\:#// ~/.gtk-match-openbox-info
sed -i s/tooltip_fg_color\:#// ~/.gtk-match-openbox-info
sed -i s/\"//g ~/.gtk-match-openbox-info
# force \n to be a true line break so colours on individual lines
sed -i s/\n/\\n/g ~/.gtk-match-openbox-info
sed -i 's/\\//g' ~/.gtk-match-openbox-info
#
# store some colours for use in Openbox theme
# don't delete (!d) line number n and place it in a text file colournX
# where X is used later to aid production of Openbox theme
sed '1!d' ~/.gtk-match-openbox-info > /tmp/colour1V
sed '2!d' ~/.gtk-match-openbox-info > /tmp/colour2W
sed '3!d' ~/.gtk-match-openbox-info > /tmp/colour3X
sed '4!d' ~/.gtk-match-openbox-info > /tmp/colour4Y
sed '5!d' ~/.gtk-match-openbox-info > /tmp/colour5Z
#
# check if we have empty data from unhandled GTK themes
myfile="/tmp/colour1V"
emptycheck
myfile="/tmp/colour2W"
emptycheck
myfile="/tmp/colour3X"
emptycheck
myfile="/tmp/colour4Y"
emptycheck
myfile="/tmp/colour5Z"
emptycheck
#
# hold the above in varibles
myV=$(cat /tmp/colour1V)
myW=$(cat /tmp/colour2W)
myX=$(cat /tmp/colour3X)
myY=$(cat /tmp/colour4Y)
myZ=$(cat /tmp/colour5Z)
#
# make Openbox theme by replacing VWXYZ in template with colours
sed s/VVVVVV/$myV/g ~/.themes/obthemetemplate/openbox-3/TEMPLATE > /tmp/obtheme
sed -i s/WWWWWW/$myW/g /tmp/obtheme
sed -i s/XXXXXX/$myX/g /tmp/obtheme
sed -i s/YYYYYY/$myY/g /tmp/obtheme
sed s/ZZZZZZ/$myZ/g /tmp/obtheme > ~/.themes/obthemetemplate/openbox-3/themerc
#
# update rc.xml
#urxvt -e /usr/bin/obconf

3) AND you need this folder in your ~/.themes/ folder - download it, extract and copy to ~/.themes

4) (optional but welcome) Post your fails, post your abusive and constructive criticism, and post your "hey why don't you use this 5million times better version here?"'s

thanks, bye

Offline

#2 2010-08-18 17:42:41

null
Member
Registered: 2009-05-06
Posts: 398

Re: Openbox Theme from GTK theme [beta]

Works fine here. Thanks for the script, it's quite handy and I got at last a nice OB theme witch fits with the murrina chrome gtk theme wink

Offline

Board footer

Powered by FluxBB