Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Last active July 10, 2017 14:03
Show Gist options
  • Save DennisLfromGA/5978373be956759a2e92 to your computer and use it in GitHub Desktop.
Save DennisLfromGA/5978373be956759a2e92 to your computer and use it in GitHub Desktop.
Simple command line tool which will grab a random wallpaper # from the Chromecast backgrounds repository at # https://github.com/dconnolly/chromecast-backgrounds
#!/bin/bash
# Chromecast-daily-wallpaper
# Version 0.2
#
# Simple command line tool which will grab a random wallpaper
# from the Chromecast backgrounds repository at
# https://github.com/dconnolly/chromecast-backgrounds
#
# Depends: lynx, nitrogen
#
# Created by RichJack, 2015 designed for Chromixium OS:
# http://chromixium.org
#
# Tweaked by DennisL to Version 0.2
# Options:
# - With no arguments, the script will restore the 'nitrogen' saved image. (I.E.) `chromecast-daily-wallpaper`
# - With any argument(s), the script will get and save an updated, random image. (I.E.) `chromecast-daily-wallpaper update`
# DennisLfromGA@github.com
#
# Licence: GPL v3
#
# Chromecast-daily-wallpaper is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# Chromecast-daily-wallpaper is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Chromecast-daily-wallpaper. If not, see
# <http://www.gnu.org/licenses/>.
tempfile=/tmp/dailywallpaper.txt
imagfile=/tmp/dailywallpaper.jpg
if [ ! -r $imagfile -o -n "$1" ]
then
lynx -dump https://github.com/dconnolly/chromecast-backgrounds | awk '/githubusercontent/{print $2}' > $tempfile
TOTAL=$(wc -l < $tempfile)
# Got this from http://crunchbang.org/forums/viewtopic.php?id=11374
RandomNumber=$(( $RANDOM % $TOTAL ))
test ! $RandomNumber = 0 || RandomNumber=1
DAILY=$(sed -n "${RandomNumber}p" $tempfile)
wget -qO /tmp/dailywallpaper.${RandomNumber}.jpg $DAILY
ln -sf /tmp/dailywallpaper.${RandomNumber}.jpg $imagfile
fi
nitrogen --set-scaled --save $imagfile
@helynranta
Copy link

nitrogen didnt work for me, so i change last line to
gsettings set org.gnome.desktop.background picture-uri $imagfile

and now it works perfectly -b
ubuntu gnome 15.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment