Last active
October 26, 2017 14:39
-
-
Save goodevilgenius/5544852 to your computer and use it in GitHub Desktop.
[Random Wallpaper] Scraper to get a random wallpaper from various websites. Most are broken. Uses fbsetbg (fluxbox) and gsettings (Gnome 3/Unity) to set background. #desktop #obsolete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMG_DIRECTORY="${HOME}/.random_wallpaper" | |
function setit() { | |
fbsetbg -a "$(readlink -f "$1")" | |
gsettings set org.gnome.desktop.background picture-uri "file://$(readlink -f "$1")" | |
} | |
function flik() { | |
echo "flikie.com" | |
url="$(curl http://www.flikie.com/ | sed -nr 's/.*src="([^"]+)-[0-9]+x[0-9]+.(jpg|png)" class="featured-hover-random.*/\1.\2/p' | head -1)" | |
curl -O "$url" | |
setit "$(basename "$url")" | |
} | |
function wallbase() { | |
echo "wallbase.cc" | |
wget --no-use-server-timestamps $(curl $(curl http://wallbase.cc/random/23/eqeq/1920x1080/0/100/20 | grep 'wallpaper/' | awk -F'"' '{print $2}' | head -n1) | grep -A4 bigwall | grep img | awk -F'"' '{print $2}') | |
setit $(ls -1t | head -n1) | |
} | |
function free4u() { | |
echo "free4uwallpapers.org" | |
id="$(curl http://www.free4uwallpapers.org/random.php | grep img_box | sed 's/></>\n</g' | sed -nr "s|.*class='img_box' src='http://www.free4uwallpapers.org/wallpapers/thumbs/([0-9]+)_thumb.jpg.*|\1|p" | head -1)" #' | |
curl -o "$id.jpg" "http://www.free4uwallpapers.org/download.php?id=${id}.jpg" | |
setit "$id.jpg" | |
} | |
function deviant() { | |
echo "deviantart.com" | |
url="$(curl "http://browse.deviantart.com/?order=24&q=wallpaper" | grep vinyl | sed 's/></>\n</g' | sed -nr 's/.*super_fullimg="([^"]+)".*/\1/p' | shuf)" #"' | |
curl -O "$url" | |
setit "$(basename "$url")" | |
} | |
function wallpaperhere() { | |
base="http://www.wallpaperhere.com" | |
echo "$base" | |
img="$(curl -L "$base/random-wallpapers" | sed -nr 's|^<a href="([^"]+)"><img src="/thumbnails.*|\1|p' | shuf | head -1)" | |
orig="$(curl -L "$base$img/download_preview" | sed -nr 's|<dd class="view_size"><a class="[^"]*" href="([^"]+)">Original Size.*|\1|p')" | |
final="$(curl -L "$base$orig" | sed -nr 's|^<img src="(/view[^"]+)".*|\1|p')" #' | |
wget "$base$final" | |
setit "$(basename "$final")" | |
} | |
if [ ! -d "$IMG_DIRECTORY" ] | |
then | |
mkdir "$IMG_DIRECTORY" | |
fi | |
pushd "$IMG_DIRECTORY" | |
i=$((RANDOM%4)) | |
if [ $i -eq 0 ] | |
then | |
flik | |
elif [ $i -eq 1 ] | |
then | |
wallbase | |
elif [ $i -eq 2 ] | |
then | |
free4u | |
elif [ $i -eq 3 ] | |
then | |
wallpaperhere | |
elif [ $i -eq -1 ] | |
then | |
deviant | |
fi | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't use this at all anymore. It's possible that it's entirely broken. I don't intend to update it, as I have no more use for it. I now use Variety to fetch and set my wallpaper.