#!/bin/bash # # #*********************************************************************** # pysy-move-generator : script to automatically generate themes for pysycache-move # Copyright (C) 2008 # Achim TRUMPLER (linux@achimtrumpler.de ) for bash and gnome part # Vincent DEROO (vincent.pysycache@free.fr) for the kde part # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc. : # 51 Franklin Street, Fifth Floor, Boston, MA02110-1301, USA #*********************************************************************** optaff=0 # 0 - script # 1 - kde option, and kdialog # 2 - gnome option, and zenity MSG1="Please enter a name (without blanks or special characters) for the theme " MSG2="Where do the caches come from ? " MSG3="manipulation and conversion of the original" MSG4="other pictures (saved in folder named cover)" MSG5="Select the directory with pictures to convert." MSG6="Please note that in this directory including subfolders all blanks in the filenames are replaced with "_"." MSG8="End of conversion. You can use pysycache" picturedir=$(pwd) for param in "$@" do if [ "$param" = "-kde" ]; then optaff=1 fi if [ "$param" = "-gnome" ]; then optaff=2 fi done # The folder in which the script is started must not include blanks or special characters. # The pictures to be used have to be in landscape format if [ $optaff == 0 ]; then #a script shell echo $MSG1 read ordner # echo $MSG5 # read picturedir echo $MSG2 echo "1 - "$MSG3 echo "2 - "$MSG4 echo "Please choose [1] or [2]" read auswahl else if [ $optaff == 1 ]; then #a kde dialog box ordner=`kdialog --title "Theme name" --inputbox "$MSG1" ` kdialog --msgbox "$MSG5 $MSG6" picturedir=`kdialog --title "$MSG5" --getexistingdirectory . ` while [ "$picturedir" != "" ] do picturedir=`kdialog --title "$MSG5" --getexistingdirectory . ` done auswahl=`kdialog --radiolist "$MSG2" 1 "$MSG3" on 2 "$MSG4" off` else #a gnome dialog box ordner=`zenity --entry --title "Theme name" --text "$MSG1" ` zenity --info --text "$MSG5 $MSG6" picturedir=`zenity --file-selection --directory --title "$MSG5" . ` while [ "$picturedir" = "" ] do picturedir=`zenity --file-selection --directory --title "$MSG5" . ` done auswahl=`zenity --list --radiolist --width=400 --height=170 --text "$MSG2" --title "Method selection" --column="" --column="" --column "Description" "" "1" "$MSG3" "" "2" "$MSG4"` fi fi echo $ordner, $picturedir, $auswahl cd $picturedir # The folder in which the script is started must not include blanks or special characters. # blanks in file names will be erased find . -name "* *" | while read a ; do mv "${a}" "${a//\ /_}" ; done # creation of the cache directory #test if [ ! -e cache ] then mkdir cache fi # Saving the originals. Please uncomment the next two lines if not required #test if [ ! -e original ] then mkdir orginal fi cp *.jp*g orginal cp *.png original if [ "$auswahl" = "1" ]; then # all pictures of the directory files=$(ls *.j*pg); for i in $files; do name=$(echo $i | cut -f1 -d"."); echo a.$i, >> $name.dfg echo b.$i, >> $name.dfg echo c.$i, >> $name.dfg echo d.$i, >> $name.dfg echo e.$i, >> $name.dfg # echo f.$i, >> $name.dfg # echo g.$i, >> $name.dfg #echo h.$i, >> $name.dfg # The pictures in the foreground, which will get erased, are created. # Therefore imagemagick filters are used. Please change parameter or filters if you want to. # The pictures are scaled to required format of 720x540. # Pictures in portrait format or pictures not in ratio 4:3 will get compressed convert $i -resize 720x540\! $i convert $i -noise 10 cache/a.$i convert $i -charcoal 5 cache/b.$i convert $i -paint 5 cache/c.$i convert $i -colorspace Gray -emboss 0x1.1 cache/d.$i convert $i -blur 0x8 cache/e.$i #convert $i -blur 0x2 -shade 120x45 cache/f.$i #convert $i.jpg -paint 5 cache/g.$i #convert $i.jpg -gaussian 10 cache/h.$i done else #pictures located in the cover directory files=$(ls *.j*pg); cd cover cover=$(ls *.j*pg); cd .. for j in $cover; do echo $j, >> config.dfg convert cover/$j -resize 720x540\! cache/$j; done for i in $files; do name=$(echo $i | cut -f1 -d"."); cp config.dfg $name.dfg convert $i -resize 720x540\! $i done fi # Standard logo is used as logo for this theme cp /usr/share/pysycache/doc/Elements-For-Themes/masque-button-theme.png ./logo.png # Activate the next 2 lines if you want to modify the standard logo before copying the files to pysycache themes folder # echo "You can now modify the logo of the theme before the files are copied. When finished, please hit any key" # read # Copying the files into the pysycache folder of the user (folder name might be different) mkdir /home/$USER/pysycache/themes-move/$ordner cp ./*.jpg /home/$USER/pysycache/themes-move/$ordner cp ./*.dfg /home/$USER/pysycache/themes-move/$ordner cp ./cache /home/$USER/pysycache/themes-move/$ordner -R if [ $optaff == 0 ]; then #a script shell echo $MSG8 else if [ $optaff == 1 ]; then kdialog --msgbox "$MSG8" else zenity --info --text "$MSG8" fi fi exit 0