]> git.wh0rd.org - home.git/blob - .bin/randomwallpaper
cros-board: update
[home.git] / .bin / randomwallpaper
1 #!/bin/bash
2
3 [[ ${SVCNAME} == "dcron" ]] && exec >& /dev/null
4
5 [ -e ~/.nowallpaper ] && exit 0
6 #[ -z "`pgrep X-life-line`" ] && exit 0
7
8 WALLPAPEROPTS="-s"
9 WALLPAPERPROG="Esetroot"
10
11 WALLPAPERDIRS="
12 /usr/share/pixmaps/wallpapers/active
13 "
14
15 WALLPAPERCOUNT=0
16 for dir in ${WALLPAPERDIRS} ; do
17 tmpcnt=`ls ${dir} | wc -l`
18 WALLPAPERCOUNT=$((${WALLPAPERCOUNT} + ${tmpcnt}))
19 done
20 [ ${WALLPAPERCOUNT} -eq 0 ] && exit 0
21 WP=`expr ${RANDOM} % ${WALLPAPERCOUNT} + 1`
22
23 [ -z "$1" ] \
24 && WALLPAPER="`find ${WALLPAPERDIRS} -maxdepth 1 -type f -o -type l | cut -d$'\n' -f ${WP}`" \
25 || WALLPAPER="$1"
26
27 ${WALLPAPERPROG} ${WALLPAPEROPTS} "${WALLPAPER}"
28