Skip to content

Instantly share code, notes, and snippets.

@lesthack
Created December 19, 2018 20:44

Revisions

  1. lesthack created this gist Dec 19, 2018.
    20 changes: 20 additions & 0 deletions autowallpaper.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #/bin/bash

    # Paths
    home_path="/home/user"
    wallpapers_path="$home_path/Wallpapers"

    # Test Internet Connection
    wget -q --spider http://google.com

    if [ $? -eq 0 ]; then
    echo "Download to Internet"
    wallpaper_name=`date +"%s%3N"`.jpg
    wget -O "$wallpapers_path/$wallpaper_name" https://unsplash.it/2560/1440/?random
    else
    echo "Set last wallpaper"
    wallpaper_name=`ls -t $wallpapers_path | head -1`
    fi
    ln -sf "$wallpapers_path/$wallpaper_name" /tmp/wallpaper.jpg
    gsettings set org.gnome.desktop.background picture-uri "file:///tmp/wallpaper.jpg"