HOW-TO Change the image of the login page every day since bing


I share my script for change the image of the login page every day since bing.
It’s for french user, you can change the bing market in this line:

And change resolution with this line:

You must also install jpegtran to optimize the picture
on debian:
apt-get install jpegtran


#$bing is needed to form the fully qualified URL for
#the Bing pic of the day

#$xmlURL is needed to get the xml data from which
#the relative URL for the Bing pic of the day is extracted

#The mkt parameter determines which Bing market you would like to
#obtain your images from.
#Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA.

#The idx parameter determines where to start from. 0 is the current day,
#1 the previous day, etc.

#$saveDir is used to set the location where Bing pics of the day
#are stored. $HOME holds the path of the current user’s home directory

#Create saveDir if it does not already exist
mkdir -p $saveDir

#Set picture options
#Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned

#The desired Bing picture resolution to download
#Valid options: “_1024x768” “_1280x720” “_1366x768” “_1920x1200"

#The file extension for the Bing pic

#Extract the relative URL of the Bing pic of the day from
#the XML data retrieved from xmlURL, form the fully qualified
#URL for the pic of the day, and store it in $picURL

#Form the URL for the desired pic resolution
desiredPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP “(.*)” | cut -d “>” -f 2 | cut -d “<” -f 1)$desiredPicRes$picExt

#Form the URL for the default pic resolution
defaultPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP “(.*)” | cut -d “>” -f 2 | cut -d “<” -f 1)

#$picName contains the filename of the Bing pic of the day

#Attempt to download the desired image resolution. If it doesn’t
#exist then download the default image resolution
if wget --quiet --spider "$desiredPicURL"

#Set picName to the desired picName
#Download the Bing pic of the day at desired resolution
curl -s -o $saveDir$picName $desiredPicURL

#Set picName to the default picName
#Download the Bing pic of the day at default resolution
curl -s -o $saveDir$picName $defaultPicURL

jpegtran -copy none -progressive -optimize /tmp/BingDesktopImages/$picName > /var/www/nextcloud/core/img/background.jpg
chown www-data /var/www/nextcloud/core/img/background.jpg
rm /tmp/BingDesktopImages/$picName

#Exit the script

1 Like