#!/bin/ksh ## ## script: buftheme ## ## Maintains the Buffalo Themes ## # Programmer: H.C. King 10 Jun 2004 setTheme() { cd /usr/local/share/icewm/themes cat <<-THEME >~/.icewm/theme Theme="$1/default.theme" THEME /usr/local/bin/getBuffaloColor if [ $# -lt 3 ] then /usr/local/bin/clrxfbd darkcyan echo darkcyan ~/.bgcolor return fi echo $2 | tr '/' ' ' | read style style2 if [ "$style" ] then /usr/bin/switch /usr/share/themes/$style fi if [ "$style2" ] then /usr/bin/switch2 /usr/share/themes/$style2 fi echo $3 >~/.bgcolor if [ "$4" = auto ] then bg='' else bg=$4 fi sty=auto if [ $# -gt 4 ] then sty=$5 fi cat <<-BKGD >~/.xfce/xfbdrc /usr/local/share/backgrounds/$bg $sty BKGD Xfbd } if [ ! -r ~/.buftheme ] then cat <<-BUFTHEME >~/.buftheme 1:BuffaloGold:buffalo:Metal:darkcyan:buffalo.png 2:BuffaloGreen:buffalo:Metal:darkcyan:buffalo2.png 3:XP:xp:Aqua:darkcyan:field.jpg 4:Windows:win95:Redmond95:darkcyan:: BUFTHEME fi Xdialog --title Buffalo --no-tags --radiolist "Buffalo Themes" 20 25 18 `cut --output-delimiter=' ' -d: -f1,2,3 ~/.buftheme` -1 "Save Theme" x -2 "Delete Theme" x -3 "Export Theme" x 2>&1 | read ans err=$? set - '' shift set - `echo $ans | grep error` if [ $err -ne 0 -o $# -gt 0 ] then exit fi if [ "$ans" -eq -1 ] then Xdialog --title Buffalo -inputbox "Theme Name" 9 30 2>&1 | read ans if [ $? -ne 0 -o ! "$ans" ] then exit fi echo $ans | read name rest wc -l ~/.buftheme | read lne rest lne=`expr $lne + 1` cut -d'"' -f2 ~/.icewm/theme | cut -d/ -f1 | read theme head -1 ~/.bgcolor | read color grep /share/backgrounds/ ~/.xfce/xfbdrc | sed 's/backgrounds/ /' | read a bkgd c echo $bkgd | cut -d/ -f2 | read bkgd grep /share/themes/ ~/.gtkrc | sed 's/themes/ /'| read a b style d echo $style | cut -d/ -f2 | read style grep /share/themes/ ~/.gtkrc-2.0 | sed 's/themes/ /'| read a b style2 d echo $style2 | cut -d/ -f2 | read style2 style=$style/$style2 tail -1 ~/.xfce/xfbdrc | read typ printf "%s:%s:%s:%s:%s:%s %s\n" $lne $name "$theme" "$style" "$color" "$bkgd" "$typ" >>~/.buftheme exit fi if [ "$ans" -eq -2 ] then Xdialog --title Buffalo --no-tags --radiolist "Delete Theme" 20 25 18 `cut --output-delimiter=' ' -d: -f1,2,3 ~/.buftheme` 2>&1 | read ans if [ $? -ne 0 -o ! "$ans" ] then exit fi n=0 head -$ans ~/.buftheme | tail -1 | read ans rm -f /tmp/buftheme.$$ grep -v "$ans" ~/.buftheme | cut -d: -f2- | while read lne do n=`expr $n + 1` printf "%d:%s\n" $n "$lne" >>/tmp/buftheme.$$ done mv /tmp/buftheme.$$ ~/.buftheme exit fi if [ "$ans" -eq -3 ] then Xdialog --title Buffalo --no-tags --radiolist "Export Theme" 20 25 18 `cut --output-delimiter=' ' -d: -f1,2,3 ~/.buftheme` 2>&1 | read ans if [ $? -ne 0 -o ! "$ans" ] then exit fi ifs=$IFS export IFS=: head -$ans ~/.buftheme | tail -1 | read num name ice gtk bgcolor bgimage export IFS=$ifs mkdir /tmp/bthemes.$$ cd /tmp/bthemes.$$ umask 0 mkdir install mkdir -p usr/local/share/backgrounds mkdir -p usr/local/share/icewm/themes mkdir -p usr/share/themes cd usr/share/themes echo $gtk | tr '/' ' ' | read gtk gtk2 cp -R /usr/share/themes/$gtk . if [ "$gtk2" ] then cp -R /usr/share/themes/$gtk2 . fi cd /tmp/bthemes.$$/usr/local/share/icewm/themes cp -R /usr/local/share/icewm/themes/$ice . cd /tmp/bthemes.$$/usr/local/share/backgrounds set - $bgimage cp /usr/local/share/backgrounds/$1 . cd /tmp/bthemes.$$/install cat <<-DOINST_SH >doinst.sh #!/bin/ksh if [ -d /usr/X11R6/share/themes ] then cd /usr/X11R6/share/themes mv * /usr/share/themes 2>/dev/null cd .. rm -rf themes fi ( cd /usr/X11R6/share ; ln -s ../../share/themes . 2>/dev/null ) for fle in /home/*/.buftheme do if [ ! "\`grep :$name: \$fle 2>/dev/null\`" ] then wc -l \$fle| read lne rest lne=\`expr \$lne + 1\` printf "%s:%s:%s:%s:%s:%s\n" \$lne "$name" "$ice" "$gtk/$gtk2" "$bgcolor" "$bgimage" >>\$fle fi done if [ ! "\`grep :$name: /opt/buffalo/BufThemes 2>/dev/null\`" ] then printf ":%s:%s:%s:%s:%s\n" "$name" "$ice" "$gtk/$gtk2" "$bgcolor" "$bgimage" >>/opt/buffalo/BufThemes fi DOINST_SH chmod 755 doinst.sh cd .. tar cjf ../$name-theme-buff-2.bz2 * cd .. rm -rf /tmp/bthemes.$$ Xdialog --title "$name" --msgbox "Theme $name-theme-buff-2.bz2 located in /tmp" 0 0 exit fi if [ "$ans" ] then setTheme `head -$ans ~/.buftheme | tail -1 | cut -d: -f3- | tr ':' ' '` Xdialog --title Buffalo --infobox "Restart ICEWM" 6 20 4000 else xmessage -center -timeout 7 -file - <<-BADGTK Entry ERROR Likely an unsupported GTK Theme Choose another GTK Style BADGTK fi