Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Random Backgrounds, script that changes bg every 5 minutes< Next Oldest | Next Newest >
jshaw Offline





Group: Members
Posts: 42
Joined: July 2004
Posted: Mar. 02 2005,08:21 QUOTE

I found this script on the web and modified it a little for DSL.  As shown here it will use /home/dsl/.fluxbox/backgrounds/ for the images.  I saved this code as setrandbg.sh and made it executable.

[CODE]
#!/bin/sh
# by Benjamin Okopnik <ben-fuzzybear@geocities.com>
# *** bkgr *** - A random background selector for XFree86

# Define the dir where the pictures are kept
PIC_DIR=/home/dsl/.fluxbox/backgrounds

# Create a unique tempfile name and save all PIC_DIR filenames into it
TMPFILE=$(mktemp /tmp/temp.XXXXXX)
ls $PIC_DIR/* > $TMPFILE 2> /dev/null
for ((  i = 0 ;  i <= 0;  i  ))
do

# A) Gen a random # (0 - 32767). B) Confine it to a range of (1 - <picfile_count>).
# C) Set $FNM to the filename on line $RANDOM in the $TMPFILE.
FNM=$(head -$(($RANDOM / (32768 / $(grep -c . $TMPFILE)) + 1)) $TMPFILE | tail -1)

# This allows a pic name to be entered as an arg to bkgr - "Honey! You
# should see this KEWL background that came up!" :) Anyway, check if the
# file exists (if an arg is entered) and substitute it for the random one.
if [ -f $PIC_DIR/$1 ]
then
   FNM=$PIC_DIR/$1
fi

# Tell me the name for future reference - or, provide a doublecheck if
# I do enter an arg ("Yep, I'm using the pic that you specified.")
echo -n "Using "
basename $FNM

# Build in a 'wait-loop' to avoid a race condition with the WM -
# replace "icewm" with your own window manager's name.
while [ -z "$ICE" ]
do
   ICE=$(ps ax | grep fluxbox)
   sleep 2
done

# Handle the pics differently based on size; I've found 20kB
# to be a good breakpoint for my JPGs and PNGs...

   bsetbg -f $FNM &

sleep 5m

done
# Clean up...
rm $TMPFILE


# ...and exit gracefully.
exit 0


# "Y'all come back now, y'hear?" :)
[QUOTE]

josh


--------------
Dell Optiplex GX100 - Painted Flat Black
Celeron 566
256 MB RAM
NVIDIA GeForce 4400MX - Onboard graphics are crap
Old Sound Card
ProView 19" Widescreen 1440x900 native resolution
   (thanks XFree86 and nvidia2 extensions)
DSL 4.2.5 ROCKS on this machine!
Back to top
Profile PM 
0 replies since Mar. 02 2005,08:21 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Random Backgrounds

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code