Pejman Moghadam / Scripts

Bash script - Changing wallpaper randomly using feh from crontab


/home/pejman/scripts/change-wallpaper.sh

#!/bin/bash
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin"
DIR="/home/pejman/Downloads/Wallpaper/"
FNAME=$(ls "$DIR" | while read x; do echo "`expr $RANDOM % 1000`:$x"; done | sort -n | sed 's/[0-9]*://' | head -n 1)
DISPLAY=:0 feh --bg-scale "$DIR/$FNAME"

Commands

chmod +x /home/pejman/scripts/change-wallpaper.sh

crontab -e

0 * * * * /home/pejman/scripts/change-wallpaper.sh &> /dev/null

BY: Pejman Moghadam
TAG: cron, feh, wallpaper, bash, random
DATE: 2013-12-24 22:59:29


Pejman Moghadam / Scripts [ TXT ]