patch from Han, minor fixes and fbsetbg random background

This commit is contained in:
fluxgen 2003-12-29 00:00:28 +00:00
parent ea184b3566
commit 5286977393
4 changed files with 64 additions and 18 deletions

View file

@ -19,4 +19,4 @@ menu: ../util/fluxbox-generate_menu
../util/fluxbox-generate_menu ../util/fluxbox-generate_menu
../util/fluxbox-generate_menu: ../util/fluxbox-generate_menu:
cd ../util && make fluxbox-generate_menu cd ../util && ${MAKE} fluxbox-generate_menu

View file

@ -32,8 +32,8 @@ fluxbox-generate_menu: fluxbox-generate_menu.in
-chmod 755 fluxbox-generate_menu -chmod 755 fluxbox-generate_menu
../src/FbRootWindow.o: ../src/FbRootWindow.o:
cd ../src && make FbRootWindow.o cd ../src && ${MAKE} FbRootWindow.o
../src/I18n.o: ../src/I18n.o:
cd ../src && make I18n.o cd ../src && ${MAKE} I18n.o
../src/FbAtoms.o: ../src/FbAtoms.o:
cd ../src && make FbAtoms.o cd ../src && ${MAKE} FbAtoms.o

View file

@ -23,7 +23,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# #
# $Id: fbsetbg,v 1.25 2003/12/12 13:07:47 fluxgen Exp $ # $Id: fbsetbg,v 1.26 2003/12/28 23:59:57 fluxgen Exp $
# Portability notes: # Portability notes:
# To guarantee this script works on all platforms that support fluxbox # To guarantee this script works on all platforms that support fluxbox
@ -59,7 +59,9 @@ command="`basename \"$0\"`"
# Functions # Functions
display_usage() { display_usage() {
cat << EOF cat << EOF
Usage: $command [-u/-U [wallpapersetter]] [-fFcCtTaA /path/to/wallpaper] [-bB bsetrootoptions] [-l] [-h] [-i] [-p] Usage: $command [-u/-U [wallpapersetter]] [-fFcCtTaA /path/to/wallpaper]
[-r/-R /path/to/wallpaperdirectory]
[-b/-B bsetrootoptions] [-l] [-h] [-i] [-p]
Use \`\`$command -h'' for a complete help message. Use \`\`$command -h'' for a complete help message.
EOF EOF
@ -79,8 +81,9 @@ Options:
we fall back to -f ) we fall back to -f )
-u Use specified wallpapersetter, use no argument to forget. -u Use specified wallpapersetter, use no argument to forget.
-b Forward the options to bsetroot. -b Forward the options to bsetroot.
-r set random wallpaper from a directory
-F,-C,-T,-A,-U,-B same as uncapsed but without remembering. -F,-C,-T,-A,-U,-B,-R same as uncapsed but without remembering.
-h Display this help. -h Display this help.
@ -259,7 +262,14 @@ while [ $# -gt 0 ]; do
shift shift
wallpaper=$* wallpaper=$*
remember=false remember=false
break;; break ;;
-r) option=random
wallpaper=$2 # in this case it's a dir
break ;;
-R) option=random
wallpaper=$2 # in this case it's a dir
remember=false
break ;;
-l) -l)
if [ -r "$lastwallpaper" ]; then if [ -r "$lastwallpaper" ]; then
option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
@ -270,8 +280,7 @@ while [ $# -gt 0 ]; do
fi fi
fi fi
remember=false remember=false
break break ;;
;;
-p) display_tips ; exit 0 ;; -p) display_tips ; exit 0 ;;
-h) display_help ; exit 0 ;; -h) display_help ; exit 0 ;;
--) --)
@ -282,10 +291,11 @@ while [ $# -gt 0 ]; do
-*) -*)
message "unrecognized option "\`"$1'" message "unrecognized option "\`"$1'"
display_usage display_usage
exit 1 exit 1 ;;
;;
*) *)
if [ ! -r "$1" ]; then if [ "$option" = random ]; then
option='$aspect'
elif [ ! -r "$1" ]; then
message "$1 isn't an existing wallpaper or a valid option." message "$1 isn't an existing wallpaper or a valid option."
display_usage display_usage
exit 1 exit 1
@ -296,8 +306,7 @@ while [ $# -gt 0 ]; do
else else
wallpaper=$1 wallpaper=$1
break break
fi fi ;;
;;
esac esac
done done
@ -410,7 +419,7 @@ recommend you install the package provided by your distro."
;; ;;
esac esac
if [ "$debug" = true ];then if [ "$debug" = true ]; then
debugfbsetbg debugfbsetbg
exit 0 exit 0
fi fi
@ -419,11 +428,12 @@ option=${option:='$full'}
if [ -z "$DISPLAY" ];then if [ -z "$DISPLAY" ]; then
message "You are not connected to an X session\nPerhaps you should set the DISPLAY environment variable?" message "You are not connected to an X session\nPerhaps you should set the DISPLAY environment variable?"
exit 1 exit 1
fi fi
if [ "$option" = bsetroot ]; then if [ "$option" = bsetroot ]; then
bsetroot $wallpaper bsetroot $wallpaper
if [ ! "$remember" = false ]; then if [ ! "$remember" = false ]; then
@ -432,11 +442,45 @@ if [ "$option" = bsetroot ]; then
exit 0 exit 0
fi fi
# random wallpaper code
if [ "$option" = random ]; then
# Lets make one thing clear...
wallpaperdir=$wallpaper
if [ -z "$wallpaperdir" ]; then
message "No random wallpaper directory specified."
exit 1
fi
if [ -d "$wallpaperdir" ]; then
number_of_wallpapers=`ls $wallpaperdir|wc -l`
# some shells don't support $RANDOM
if [ -z $RANDOM ]; then
randomnumber=`(echo $$ ;time ps; w ; date )2>&1 | cksum | cut -f1 -d' '`
else
randomnumber=$RANDOM
fi
wallpapernumber=`expr $randomnumber % $number_of_wallpapers + 1`
#remember previous wallpaper
if [ ! "$remember" = false ]; then
remembercommand
fi
remember=false
#set -x
wallpaper="$wallpaperdir/`ls $wallpaperdir|sed -n ${wallpapernumber}p`"
option='$aspect' # have to choose something...
else
message "Invalid random wallpaper directory specified."
exit 1
fi
fi
if [ ! -r "$wallpaper" ]; then if [ ! -r "$wallpaper" ]; then
message "Can't find wallpaper $wallpaper" message "Can't find wallpaper $wallpaper"
exit 1 exit 1
fi fi
$WPSETTER `eval echo $option` "$wallpaper" $WPSETTER `eval echo $option` "$wallpaper"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
message "Something went wrong while setting the wallpaper. message "Something went wrong while setting the wallpaper.
@ -444,6 +488,7 @@ Run '$WPSETTER "`eval echo $option` $wallpaper"' from an xterm to find out what.
exit 1 exit 1
fi fi
#remember previous wallpaper #remember previous wallpaper
if [ ! "$remember" = false ]; then if [ ! "$remember" = false ]; then
remembercommand remembercommand

View file

@ -22,7 +22,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# $Id: fluxbox-generate_menu.in,v 1.5 2003/12/22 01:19:02 fluxgen Exp $ # $Id: fluxbox-generate_menu.in,v 1.6 2003/12/28 23:59:57 fluxgen Exp $
# #
# Portability notes: # Portability notes:
@ -1014,6 +1014,7 @@ append_submenu "${FBSETTINGSMENU}"
NUMBER_OF_BACKGROUNDS=`find $BACKGROUND_DIRS -follow -type f 2> /dev/null|wc -l` NUMBER_OF_BACKGROUNDS=`find $BACKGROUND_DIRS -follow -type f 2> /dev/null|wc -l`
if [ "$NUMBER_OF_BACKGROUNDS" -gt 0 ]; then if [ "$NUMBER_OF_BACKGROUNDS" -gt 0 ]; then
append_menu "[submenu] (${BACKGROUNDMENU}) {${BACKGROUNDMENUTITLE}}" append_menu "[submenu] (${BACKGROUNDMENU}) {${BACKGROUNDMENUTITLE}}"
append "[exec] (random background) {fbsetbg -r ${HOME}/.fluxbox/backgrounds}"
if [ "$NUMBER_OF_BACKGROUNDS" -gt 30 ]; then if [ "$NUMBER_OF_BACKGROUNDS" -gt 30 ]; then
menucounter=1 ; counter=1 menucounter=1 ; counter=1
append_menu "[submenu] (${BACKGROUNDMENU} $menucounter) {${BACKGROUNDMENUTITLE}}" append_menu "[submenu] (${BACKGROUNDMENU} $menucounter) {${BACKGROUNDMENUTITLE}}"