#!/bin/bash
# ref: http://pastebin.com/f528ad5d2
# 可以用 cron 執行的正妹計時器, 更換 ubuntu gnome 桌面背景.
# 2010-1212 alston
mydir=~/ar/girlclock/
hmfile=`date +"%H%M"`.JPG
## Get and export the DBUS_SESSION_BUS_ADDRESS for crontab compatibility
nautilus_pid=$(pgrep -u $LOGNAME -n nautilus)
eval $(tr '\0' '\n' < /proc/$nautilus_pid/environ | grep '^DBUS_SESSION_BUS_ADDRESS=')
export DBUS_SESSION_BUS_ADDRESS
if [ ! -e $mydir/$hmfile ];then
wget http://gameflier.lovelytime.com.tw/photo/$hmfile -O $mydir/$hmfile
fi
/usr/bin/gconftool-2 --type string -s /desktop/gnome/background/picture_filename $mydir/$hmfile