summaryrefslogtreecommitdiff
path: root/util/fbsetbg
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-12-29 00:00:28 (GMT)
committerfluxgen <fluxgen>2003-12-29 00:00:28 (GMT)
commit52869773937f18146f60b617e6c0618bbf40d751 (patch)
tree0eff0ba31d80cf9ae35b6b19d9f7612445a3e60c /util/fbsetbg
parentea184b3566bfee3f720763edf4e11cd27e9cd1d0 (diff)
downloadfluxbox_lack-52869773937f18146f60b617e6c0618bbf40d751.zip
fluxbox_lack-52869773937f18146f60b617e6c0618bbf40d751.tar.bz2
patch from Han, minor fixes and fbsetbg random background
Diffstat (limited to 'util/fbsetbg')
-rw-r--r--util/fbsetbg71
1 files changed, 58 insertions, 13 deletions
diff --git a/util/fbsetbg b/util/fbsetbg
index c053ea2..73f2111 100644
--- a/util/fbsetbg
+++ b/util/fbsetbg
@@ -23,7 +23,7 @@
23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25# 25#
26# $Id: fbsetbg,v 1.25 2003/12/12 13:07:47 fluxgen Exp $ 26# $Id: fbsetbg,v 1.26 2003/12/28 23:59:57 fluxgen Exp $
27 27
28# Portability notes: 28# Portability notes:
29# To guarantee this script works on all platforms that support fluxbox 29# To guarantee this script works on all platforms that support fluxbox
@@ -59,7 +59,9 @@ command="`basename \"$0\"`"
59# Functions 59# Functions
60display_usage() { 60display_usage() {
61 cat << EOF 61 cat << EOF
62Usage: $command [-u/-U [wallpapersetter]] [-fFcCtTaA /path/to/wallpaper] [-bB bsetrootoptions] [-l] [-h] [-i] [-p] 62Usage: $command [-u/-U [wallpapersetter]] [-fFcCtTaA /path/to/wallpaper]
63 [-r/-R /path/to/wallpaperdirectory]
64 [-b/-B bsetrootoptions] [-l] [-h] [-i] [-p]
63Use \`\`$command -h'' for a complete help message. 65Use \`\`$command -h'' for a complete help message.
64 66
65EOF 67EOF
@@ -79,8 +81,9 @@ Options:
79 we fall back to -f ) 81 we fall back to -f )
80 -u Use specified wallpapersetter, use no argument to forget. 82 -u Use specified wallpapersetter, use no argument to forget.
81 -b Forward the options to bsetroot. 83 -b Forward the options to bsetroot.
84 -r set random wallpaper from a directory
82 85
83 -F,-C,-T,-A,-U,-B same as uncapsed but without remembering. 86 -F,-C,-T,-A,-U,-B,-R same as uncapsed but without remembering.
84 87
85 -h Display this help. 88 -h Display this help.
86 89
@@ -259,7 +262,14 @@ while [ $# -gt 0 ]; do
259 shift 262 shift
260 wallpaper=$* 263 wallpaper=$*
261 remember=false 264 remember=false
262 break;; 265 break ;;
266 -r) option=random
267 wallpaper=$2 # in this case it's a dir
268 break ;;
269 -R) option=random
270 wallpaper=$2 # in this case it's a dir
271 remember=false
272 break ;;
263 -l) 273 -l)
264 if [ -r "$lastwallpaper" ]; then 274 if [ -r "$lastwallpaper" ]; then
265 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` 275 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
@@ -270,8 +280,7 @@ while [ $# -gt 0 ]; do
270 fi 280 fi
271 fi 281 fi
272 remember=false 282 remember=false
273 break 283 break ;;
274 ;;
275 -p) display_tips ; exit 0 ;; 284 -p) display_tips ; exit 0 ;;
276 -h) display_help ; exit 0 ;; 285 -h) display_help ; exit 0 ;;
277 --) 286 --)
@@ -282,10 +291,11 @@ while [ $# -gt 0 ]; do
282 -*) 291 -*)
283 message "unrecognized option "\`"$1'" 292 message "unrecognized option "\`"$1'"
284 display_usage 293 display_usage
285 exit 1 294 exit 1 ;;
286 ;;
287 *) 295 *)
288 if [ ! -r "$1" ]; then 296 if [ "$option" = random ]; then
297 option='$aspect'
298 elif [ ! -r "$1" ]; then
289 message "$1 isn't an existing wallpaper or a valid option." 299 message "$1 isn't an existing wallpaper or a valid option."
290 display_usage 300 display_usage
291 exit 1 301 exit 1
@@ -296,8 +306,7 @@ while [ $# -gt 0 ]; do
296 else 306 else
297 wallpaper=$1 307 wallpaper=$1
298 break 308 break
299 fi 309 fi ;;
300 ;;
301 esac 310 esac
302done 311done
303 312
@@ -410,7 +419,7 @@ recommend you install the package provided by your distro."
410 ;; 419 ;;
411esac 420esac
412 421
413if [ "$debug" = true ];then 422if [ "$debug" = true ]; then
414 debugfbsetbg 423 debugfbsetbg
415 exit 0 424 exit 0
416fi 425fi
@@ -419,11 +428,12 @@ option=${option:='$full'}
419 428
420 429
421 430
422if [ -z "$DISPLAY" ];then 431if [ -z "$DISPLAY" ]; then
423 message "You are not connected to an X session\nPerhaps you should set the DISPLAY environment variable?" 432 message "You are not connected to an X session\nPerhaps you should set the DISPLAY environment variable?"
424 exit 1 433 exit 1
425fi 434fi
426 435
436
427if [ "$option" = bsetroot ]; then 437if [ "$option" = bsetroot ]; then
428 bsetroot $wallpaper 438 bsetroot $wallpaper
429 if [ ! "$remember" = false ]; then 439 if [ ! "$remember" = false ]; then
@@ -432,11 +442,45 @@ if [ "$option" = bsetroot ]; then
432 exit 0 442 exit 0
433fi 443fi
434 444
445
446# random wallpaper code
447if [ "$option" = random ]; then
448 # Lets make one thing clear...
449 wallpaperdir=$wallpaper
450 if [ -z "$wallpaperdir" ]; then
451 message "No random wallpaper directory specified."
452 exit 1
453 fi
454 if [ -d "$wallpaperdir" ]; then
455 number_of_wallpapers=`ls $wallpaperdir|wc -l`
456 # some shells don't support $RANDOM
457 if [ -z $RANDOM ]; then
458 randomnumber=`(echo $$ ;time ps; w ; date )2>&1 | cksum | cut -f1 -d' '`
459 else
460 randomnumber=$RANDOM
461 fi
462 wallpapernumber=`expr $randomnumber % $number_of_wallpapers + 1`
463 #remember previous wallpaper
464 if [ ! "$remember" = false ]; then
465 remembercommand
466 fi
467 remember=false
468 #set -x
469 wallpaper="$wallpaperdir/`ls $wallpaperdir|sed -n ${wallpapernumber}p`"
470 option='$aspect' # have to choose something...
471 else
472 message "Invalid random wallpaper directory specified."
473 exit 1
474 fi
475fi
476
477
435if [ ! -r "$wallpaper" ]; then 478if [ ! -r "$wallpaper" ]; then
436 message "Can't find wallpaper $wallpaper" 479 message "Can't find wallpaper $wallpaper"
437 exit 1 480 exit 1
438fi 481fi
439 482
483
440$WPSETTER `eval echo $option` "$wallpaper" 484$WPSETTER `eval echo $option` "$wallpaper"
441if [ $? -ne 0 ]; then 485if [ $? -ne 0 ]; then
442 message "Something went wrong while setting the wallpaper. 486 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.
444 exit 1 488 exit 1
445fi 489fi
446 490
491
447#remember previous wallpaper 492#remember previous wallpaper
448if [ ! "$remember" = false ]; then 493if [ ! "$remember" = false ]; then
449 remembercommand 494 remembercommand