From 52869773937f18146f60b617e6c0618bbf40d751 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 29 Dec 2003 00:00:28 +0000 Subject: patch from Han, minor fixes and fbsetbg random background --- data/Makefile.am | 2 +- util/Makefile.am | 6 ++-- util/fbsetbg | 71 +++++++++++++++++++++++++++++++++++-------- util/fluxbox-generate_menu.in | 3 +- 4 files changed, 64 insertions(+), 18 deletions(-) diff --git a/data/Makefile.am b/data/Makefile.am index 6b50932..3fda5cc 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -19,4 +19,4 @@ 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 diff --git a/util/Makefile.am b/util/Makefile.am index 2e92c94..c5fb97a 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -32,8 +32,8 @@ fluxbox-generate_menu: fluxbox-generate_menu.in -chmod 755 fluxbox-generate_menu ../src/FbRootWindow.o: - cd ../src && make FbRootWindow.o + cd ../src && ${MAKE} FbRootWindow.o ../src/I18n.o: - cd ../src && make I18n.o + cd ../src && ${MAKE} I18n.o ../src/FbAtoms.o: - cd ../src && make FbAtoms.o + cd ../src && ${MAKE} FbAtoms.o diff --git a/util/fbsetbg b/util/fbsetbg index c053ea2..73f2111 100644 --- a/util/fbsetbg +++ b/util/fbsetbg @@ -23,7 +23,7 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # 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: # To guarantee this script works on all platforms that support fluxbox @@ -59,7 +59,9 @@ command="`basename \"$0\"`" # Functions display_usage() { 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. EOF @@ -79,8 +81,9 @@ Options: we fall back to -f ) -u Use specified wallpapersetter, use no argument to forget. -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. @@ -259,7 +262,14 @@ while [ $# -gt 0 ]; do shift wallpaper=$* 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) if [ -r "$lastwallpaper" ]; then option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` @@ -270,8 +280,7 @@ while [ $# -gt 0 ]; do fi fi remember=false - break - ;; + break ;; -p) display_tips ; exit 0 ;; -h) display_help ; exit 0 ;; --) @@ -282,10 +291,11 @@ while [ $# -gt 0 ]; do -*) message "unrecognized option "\`"$1'" 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." display_usage exit 1 @@ -296,8 +306,7 @@ while [ $# -gt 0 ]; do else wallpaper=$1 break - fi - ;; + fi ;; esac done @@ -410,7 +419,7 @@ recommend you install the package provided by your distro." ;; esac -if [ "$debug" = true ];then +if [ "$debug" = true ]; then debugfbsetbg exit 0 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?" exit 1 fi + if [ "$option" = bsetroot ]; then bsetroot $wallpaper if [ ! "$remember" = false ]; then @@ -432,11 +442,45 @@ if [ "$option" = bsetroot ]; then exit 0 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 message "Can't find wallpaper $wallpaper" exit 1 fi + $WPSETTER `eval echo $option` "$wallpaper" if [ $? -ne 0 ]; then 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 fi + #remember previous wallpaper if [ ! "$remember" = false ]; then remembercommand diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in index 8f7ba53..6391462 100755 --- a/util/fluxbox-generate_menu.in +++ b/util/fluxbox-generate_menu.in @@ -22,7 +22,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 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: @@ -1014,6 +1014,7 @@ append_submenu "${FBSETTINGSMENU}" NUMBER_OF_BACKGROUNDS=`find $BACKGROUND_DIRS -follow -type f 2> /dev/null|wc -l` if [ "$NUMBER_OF_BACKGROUNDS" -gt 0 ]; then append_menu "[submenu] (${BACKGROUNDMENU}) {${BACKGROUNDMENUTITLE}}" + append "[exec] (random background) {fbsetbg -r ${HOME}/.fluxbox/backgrounds}" if [ "$NUMBER_OF_BACKGROUNDS" -gt 30 ]; then menucounter=1 ; counter=1 append_menu "[submenu] (${BACKGROUNDMENU} $menucounter) {${BACKGROUNDMENUTITLE}}" -- cgit v0.11.2