The following howto shows you how to set your background depending on the time of day and the weather/season. Each day, you'll see a different image in the morning, mid-day, afternoon, sunset, and evening. The images will also reflect the current weather or season depending on the configuration. The images for each time of day are chosen randomly, so no two days will ever have the same set of images.
A typical day might look something like this: It's the second best thing to actually being outside!
- Download some images to get your collection started, and unpack them somewhere on your harddrive. (Here is my current collection. Click on "free" at the bottom of the page.) You'll also need to find some photos for winter and rainy days.
- Put this in ~/bin/onewithnature
Code: Select all
#!/usr/bin/python import pymetar, sys, re, os, time ## configuration section # path to wallpapers wallpaperdir = "/path/to/wallpapers/" # the closest weather station station = "KGLS" # background setter (and display) bgsetter = "DISPLAY=:0.0 /usr/bin/fbsetbg -r " ## end configuration section rf = pymetar.ReportFetcher(station) rep = rf.FetchReport() rp = pymetar.ReportParser() pr = rp.ParseReport(rep) pattern = re.compile('.*rain.*') rainy = pattern.search(pr.getWeather()) temp = pr.getTemperatureFahrenheit() if rainy: os.popen(bgsetter + wallpaperdir + 'rainy &>/dev/null') elif temp < 40: os.popen(bgsetter + wallpaperdir + 'winter &>/dev/null') else: os.popen(bgsetter + wallpaperdir + sys.argv[1] + ' &>/dev/null') - Edit the configuration section:
- Change the path to match where your image collection is.
- Set your weather station.
- Set the background setter. Since I use Fluxbox, I use fbsetbg to set the background, but you can use any background setter that supports random loading of images.
- Make ~/bin/onewithnature is executable:
Code: Select all
chmod 755 ~/bin/onewithnature - Install pymetar.
Code: Select all
$ emerge pymetar - At the prompt, type:
and put the following in your crontab:
Code: Select all
$ crontab -eCode: Select all
# CRONTAB for drei # # 1) => Minute # 2) => Hour # 3) => Day # 4) => Month # 5) => Day of week # 6) => Command # # 1) 2) 3) 4) 5) 6) # | | | | | | ## Different backgrounds to set mood depending on time of day 0 5 * * * /home/user/bin/onewithnature morning 0 11 * * * /home/user/bin/onewithnature mid-day 0 13 * * * /home/user/bin/onewithnature afternoon 0 19 * * * /home/user/bin/onewithnature sunset 0 20 * * * /home/user/bin/onewithnature evening - Adjust the sunset/evening times depending on your location.
If you come across photos that fit in any of the categories, please share them. Also, if you can think of any other categories or schemes, post them here.





