#!/bin/sh # $Id: fvwm-wallpaper,v 1.38 2005/02/22 00:53:03 neil Exp $ GMT # Fvwm-Wallpaper # by Neil W. Van Dyke # http://www.neilvandyke.org/fvwm-wallpaper/ ProgName="fvwm-wallpaper" ProgVer="2.1" # INTRODUCTION: # # Fvwm-Wallpaper is a little shell script that I kludged up to add a # wallpaper (aka "desktop background image") selector menu to the Fvwm2 # window manager. Do not try to use this unless you are already # comfortable with Unix and shell scripts. You can find the latest version # at "http://www.neilvandyke.org/fvwm-wallpaper/". # # INSTALLATION: # # 1. Put this script in one of your "bin" directories, and "chmod +x" it. # # 2. Make sure you have ImageMagick installed, for the "convert" and # "display" commands. http://www.imagemagick.org/ # # 3. Put all of your images you want to use for wallpaper in # "~/wallpaper/". If you want them to be tiled rather than scaled, put # "-tile" on the end of the base filename (e.g., "foo-tile.jpg"). # # 4. Run "fvwm-wallpaper" (this script). # # 6. Edit your "~/.fvwm2rc" file: # # a. Insert line like the following into the desired "AddToMenu" # structure: # # + "Wallpaper" Popup WallpaperMenu # # b. Add the following line to the end of the file (substitute # "/home/joebob" with your home directory): # # Read /home/joebob/wallpaper/.fvwm-menu # # 7. Restart Fvwm. # # LICENSE: # # This program is made available under the terms of the GNU General Public # License, which is described at "http://www.gnu.org/copyleft/gpl.html". # # HISTORY: # # * Version 2.1 released 2005-02-21. Moved menu and thumb files to under # wallpaper directory. Changed thumbnail generation. Currently being # used by the author under Fvwm 2.5.12. # * Version 2.0 released 2000-11-19. Converted to use ImageMagick instead # of XV. Now generates the thumbnails itself and doesn't require # manually running any separate tool. Also adds a really kludgey menu # item for updating the Wallpaper menu. # * Version 1.1 frozen 2000-11-19. # * Version 1.0 released 1999-09-02. # * Created 1999-08-23. ImageDir="${HOME}/wallpaper/" if [ ! -d "$ImageDir" ] ; then echo "${ProgName}: *ERROR* No wallpaper directory \"${ImageDir}\"." >&2 exit 1 fi ThumbDir="${ImageDir}.fvwm-thumbs/" MenuFile="${ImageDir}.fvwm-menu" #ProgDir="${HOME}/.fvwm-wallpaper/" #ThumbDir="${ProgDir}thumbs/" #MenuFile="${ProgDir}menu" # #mkdir "$ImageDir" 2> /dev/null #mkdir "$ProgDir" 2> /dev/null mkdir "$ThumbDir" 2> /dev/null echo "# This file was generated by ${ProgName} ${ProgVer} at: `date`" \ > "$MenuFile" echo "#" >> "$MenuFile" echo "# MenuFile = ${MenuFile}" >> "$MenuFile" echo "# ThumbDir = ${ThumbDir}" >> "$MenuFile" echo "# ImageDir = ${ImageDir}" >> "$MenuFile" echo "" >> "$MenuFile" echo "AddToFunc WallpaperUpdateFunc" >> "$MenuFile" echo "+ \"I\" Exec exec sh -c 'xterm -title ${ProgName} -e ${ProgName}" \ "; xterm -name FvwmWallpaperKludge -geometry 12x1+0+0 -e sh -c \"echo -n Restarting ; sleep 1\"'" \ >> "$MenuFile" echo "+ \"I\" Wait FvwmWallpaperKludge" >> "$MenuFile" echo "+ \"I\" Restart" >> "$MenuFile" echo "" >> "$MenuFile" echo "AddToMenu WallpaperMenu \"Wallpaper\" Title" >> "$MenuFile" cd "$ImageDir" if [ $? != 0 ] ; then echo "${ProgName}: *ERROR* Directory \"${XvpicsDir}\" does not exist." >&2 exit 1 fi for ImageFile in * ; do if [ "$ImageFile" = "*" ] ; then echo "${ProgName}: *WARNING* Directory \"${ImageDir}\" is empty." >&2 exit 0 fi echo -n "${ImageFile} ... " ThumbFile="${ThumbDir}${ImageFile}.xpm" MenuEntry=1 if [ -f "$ThumbFile" -a \( "$ThumbFile" -nt "$ImageFile" \) ] ; then echo "OK" else convert -size 80x60 "$ImageFile" -resize 80x60 "xpm:${ThumbFile}" if [ $? = 0 ] ; then echo "GENERATED" else echo "ERROR" MenuEntry=0 fi fi if [ "$MenuEntry" != 0 ] ; then echo -n "+ \"${ImageFile}*${ThumbFile}*\" Exec exec " >> "$MenuFile" case "$ImageFile" in *-tile.*) echo "display -window root '${ImageDir}${ImageFile}'" >> "$MenuFile" ;; *) echo "display -window root" \ "`xwininfo -root -stats | grep -e -geometry`" \ "'${ImageDir}${ImageFile}'" \ >> "$MenuFile" ;; esac fi done echo "+ \"\" Nop" >> "$MenuFile" echo "+ \"Update&!\" WallpaperUpdateFunc" >> "$MenuFile" exit 0 #EOF