Greg
Indeed.
- Messages
- 1,600
I may have posted this ages ago but I've made some improvements since. It's a script to download a random wallpaper off of interfacelift.com at a user defined interval and set it as the background.
It requires lynx (run "sudo apt-get install lynx" on Ubuntu). And make sure to set your resolution and the save directory at the top of the script.
Here it is, wallpaperer2.sh:
Save it in your home directory, open a terminal, chmod +x scriptname, ./scriptname
You can give the sleep time as an argument and also increment it using + and - once it's running.
It's kinda hacky scripting but it works. For me, at least. Tested on Ubuntu Lucid. It probably won't work with KDE how it is but if you can find the command to set the wallpaper it'd be easy to stick in there. Let me know how it works for you and if you can think of any improvements.
It requires lynx (run "sudo apt-get install lynx" on Ubuntu). And make sure to set your resolution and the save directory at the top of the script.
Here it is, wallpaperer2.sh:
Code:
#!/bin/bash
#version 2
RESOLUTION="1920x1080"
SAVEDIR="/home/greg/Pictures/Wallpaperer2/"
TIME="5" #default sleep time in minutes
if [[ -n $1 ]] ;
then TIME=$1
fi
cd
SLEEP="0"
FETCH()
{
if [ "$RESOLUTION" = "1920x1080" ];
then IFURL="http://interfacelift.com/wallpaper/downloads/random/hdtv/"
elif [ "$RESOLUTION" = "1024x768" ] || [ "$RESOLUTION" = "1280x960" ] || [ "$RESOLUTION" = "1280x1024" ] || [ "$RESOLUTION" = "1400x1050" ] || [ "$RESOLUTION" = "1400x1050" ];
then IFURL="http://interfacelift.com/wallpaper/downloads/random/fullscreen/$RESOLUTION/index.php"
elif [ "$RESOLUTION" = "1280x800" ] || [ "$RESOLUTION" = "1440x900" ] || [ "$RESOLUTION" = "1680x1050" ] || [ "$RESOLUTION" = "1920x1200" ] || [ "$RESOLUTION" = "2560x1440" ] || [ "$RESOLUTION" = "2560x1600" ];
then IFURL="http://interfacelift.com/wallpaper/downloads/random/widescreen/$RESOLUTION/index.php"
fi
echo -n "Requesting page source... "
lynx -dump $IFURL > /tmp/index.temp
echo "Done."
IMAGEURL=`cat /tmp/index.temp | grep -m 1 "$RESOLUTION.jpg" | cut -b 7-`
echo -n "Downloading wallpaper... "
lynx --source $IMAGEURL > wallpaperer2.jpg.temp
echo "Done."
NUM=$[`cat /tmp/index.temp | grep -m 1 $RESOLUTION.jpg | cut -b3-4`+1]
NAME=`cat /tmp/index.temp | grep -m 1 $NUM | cut -b5-`
NUM=$[$NUM+1]
INFOSTART=`cat /tmp/index.temp | grep -m 1 $NUM | cut -b8-9`
LINESTART=`cat /tmp/index.temp | grep -m 1 -n $NUM | cut -b1-2`
NUM=$[$NUM+1]
INFOSTOP=`cat /tmp/index.temp | grep -m 1 $NUM | cut -b5-6`
LINESTOP=$[`cat /tmp/index.temp | grep -m 1 -n $NUM | cut -b1-2`-1]
echo -n "Creating info file... "
echo -e "\n $NAME" > wallpaperer2.txt
echo " By `awk 'NR=='$LINESTART /tmp/index.temp | cut -b11-`" >> wallpaperer2.txt
LINESTART=$[LINESTART+1]
echo -e "`awk 'NR=='$LINESTART',NR=='$LINESTOP /tmp/index.temp`\n" >> wallpaperer2.txt
echo "Done."
echo -n "Setting wallpaper... "
mv wallpaperer2.jpg.temp wallpaperer2.jpg
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$PWD/wallpaperer2.jpg"
echo "Done."
DISPLAY
} #end fetch
DISPLAY()
{
clear
cat wallpaperer2.txt
if [ "$SLEEP" = "1" ];
then echo -e "Saved. Sleeping for $TIME minutes."; SLEEP="0"
else echo -e "Sleeping for $TIME minutes."
fi
MINUTES=$[$TIME*60]
read -t $MINUTES -p "[Q]uit / [S]ave & Sleep / [D] Save & Fetch / [F]etch Now " -n 1 INPUT
if [ "$INPUT" = "f" ];
then clear; echo "Fetching now."; FETCH
elif [ "$INPUT" = "d" ];
then cp wallpaperer2.jpg "$SAVEDIR"/"$NAME".jpg; clear; echo "Saved. Fetching now."; FETCH
elif [ "$INPUT" = "q" ];
then clear; echo "Exiting."; exit
elif [ "$INPUT" = "s" ];
then cp wallpaperer2.jpg "$SAVEDIR"/"$NAME".jpg; SLEEP="1"; DISPLAY
elif [ "$INPUT" = "=" ] || [ "$INPUT" = "+" ] ;
then TIME=$[ $TIME + 1 ]; DISPLAY
elif [ "$INPUT" = "-" ] ;
then {
if [[ $TIME -eq 1 ]] ;
then echo "Can't do 0."; DISPLAY
else TIME=$[ $TIME - 1 ]; DISPLAY
fi
}
fi
clear
FETCH
} #end display
if [ -e wallpaperer2.txt ] && [ -e wallpaperer2.jpg ];
then DISPLAY
else FETCH
fi
Save it in your home directory, open a terminal, chmod +x scriptname, ./scriptname
You can give the sleep time as an argument and also increment it using + and - once it's running.
It's kinda hacky scripting but it works. For me, at least. Tested on Ubuntu Lucid. It probably won't work with KDE how it is but if you can find the command to set the wallpaper it'd be easy to stick in there. Let me know how it works for you and if you can think of any improvements.