#!/bin/bash # Grab colours from the .gtkrc that XFCE writes and export them to # other applications. # Adam Sampson, ats@offog.org # Apps to set properties for; comment out those you don't want. NETSCAPE=1 # RXVT=1 # EMACS=1 ACROREAD=1 XNETLOAD=1 XEPHEM=1 # XFIG=1 XPS=1 # Extract the appropriate information. FONT=`grep "^ font" .gtkrc | tail -1 | sed "s/.*\"\(.*\)\".*/\1/g"` BGCOLOUR=`grep "^ base\[NORMAL\]" .gtkrc | tail -1 | sed "s/.*\"\(.*\)\".*/\1/g"` FGCOLOUR=`grep "^ fg\[NORMAL\]" .gtkrc | tail -1 | sed "s/.*\"\(.*\)\".*/\1/g"` BGACOLOUR=`grep "^ base\[ACTIVE\]" .gtkrc | tail -1 | sed "s/.*\"\(.*\)\".*/\1/g"` FGACOLOUR=`grep "^ fg\[ACTIVE\]" .gtkrc | tail -1 | sed "s/.*\"\(.*\)\".*/\1/g"` # Start a PID-labelled X resources file. RESFILE=resources.$$ echo >$RESFILE "! Created by xfce-export.sh" # Colours and font for Netscape. if [ "$NETSCAPE" ] ; then echo >>$RESFILE "Netscape*fontList: $FONT" echo >>$RESFILE ".netscape*fontList: $FONT" echo >>$RESFILE "Netscape*background: $BGCOLOUR" echo >>$RESFILE ".netscape*background: $BGCOLOUR" echo >>$RESFILE "Netscape*foreground: $FGCOLOUR" echo >>$RESFILE ".netscape*foreground: $FGCOLOUR" fi # Colours and font for Acrobat Reader. if [ "$ACROREAD" ] ; then echo >>$RESFILE "AcroRead*fontList: $FONT" echo >>$RESFILE "AcroRead*background: $BGCOLOUR" echo >>$RESFILE "AcroRead*foreground: $FGCOLOUR" fi # Colours and font for xps. if [ "$XPS" ] ; then echo >>$RESFILE "Xps*fontList: $FONT" echo >>$RESFILE "Xps*background: $BGCOLOUR" echo >>$RESFILE "Xps*foreground: $FGCOLOUR" fi # Colours and font for XNetload. if [ "$XNETLOAD" ] ; then echo >>$RESFILE "XNetload*font: $FONT" echo >>$RESFILE "XNetload*background: $BGCOLOUR" echo >>$RESFILE "XNetload*foreground: $FGCOLOUR" fi # Colours and font for XOsview. if [ "$XNETLOAD" ] ; then echo >>$RESFILE "XOsview*font: $FONT" echo >>$RESFILE "XOsview*background: $BGCOLOUR" echo >>$RESFILE "XOsview*foreground: $FGCOLOUR" fi # Colours and font for xfig. if [ "$XFIG" ] ; then grep "font:" /usr/lib/X11/app-defaults/Fig | sed "s/\(.*\):.*/\1: $FONT/g" >>$RESFILE grep "background:" /usr/lib/X11/app-defaults/Fig | sed "s/\(.*\):.*/\1: $BGCOLOUR/g" >>$RESFILE grep "foreground:" /usr/lib/X11/app-defaults/Fig | sed "s/\(.*\):.*/\1: $FGCOLOUR/g" >>$RESFILE fi # Colours and font for XEphem. if [ "$XEPHEM" ] ; then echo >>$RESFILE "XEphem*fontList: $FONT" echo >>$RESFILE "XEphem*background: $BGCOLOUR" echo >>$RESFILE "XEphem*foreground: $FGCOLOUR" fi # Colours for rxvt. if [ "$RXVT" ] ; then # Rxvt's resource handling isn't exactly correct: it reads # ~/.Xdefaults for itself, rather than querying the database. # Therefore, we have to edit .Xdefaults for ourself. Grrr. # .Xdefaults *must* include lines like: # !XFCE:rxvt-fg # something # !XFCE:rxvt-bg # something #echo >>$RESFILE "Rxvt.background: $BGCOLOUR" #echo >>$RESFILE "Rxvt.foreground: $FGCOLOUR" if grep -q \!XFCE:rxvt-bg .Xdefaults && grep -q \!XFCE:rxvt-fg .Xdefaults ; then cp ~/.Xdefaults ~/.Xdefaults.backup FILE=tmp.$$ echo >$FILE "/!XFCE:rxvt-bg" echo >>$FILE "+1d" echo >>$FILE ".+0i" echo >>$FILE "Rxvt.background: $BGCOLOUR" echo >>$FILE "." echo >>$FILE "/!XFCE:rxvt-fg" echo >>$FILE "+1d" echo >>$FILE ".+0i" echo >>$FILE "Rxvt.foreground: $FGCOLOUR" echo >>$FILE "." echo >>$FILE "w" ed ~/.Xdefaults <$FILE rm -f $FILE fi fi # Colours for Emacs. if [ "$EMACS" ] ; then echo >>$RESFILE "emacs.background: $BGCOLOUR" echo >>$RESFILE "emacs.foreground: $FGCOLOUR" echo >>$RESFILE "emacs.default.attributeForeground: $FGCOLOUR" echo >>$RESFILE "emacs.default.attributeBackground: $BGCOLOUR" echo >>$RESFILE "emacs.modeline.attributeForeground: $FGACOLOUR" echo >>$RESFILE "emacs.modeline.attributeBackground: $BGACOLOUR" fi # Merge in the changed resources. # cat $RESFILE xrdb -override $RESFILE rm -f $RESFILE