BingWallpaper

桌面壁纸更换成Bing.com的每日图片

项目地址:https://github.com/atskyline/BingWallpaper

其实就只是一个脚本,只是觉得二进制文件使用比较方便,所以采用C#写。

 

BingWallpaper_第1张图片

 

可配置的部分可以看config.ini

 

 

[BingWallpaper]
Time=
;时间设置 0为当天,-1为明天,1为昨天,2为后天,依次类推,不设置默认为0 ,已知可选项-1 ~ 18
Location=
;区域设置 不设置时为随机选择一个,已知可选项有en-US,zh-CN,ja-JP,en-AU,de-DE,en-NZ,en-CA
Resolution=
;下载图片分辨率设置 不设置时默认读取住屏幕分辨率,已知可选项有640x480,800x600,1024x768,1280x720,1920x1080,800x480,1366x768,1920x1200,1280x768
SavePath=D:\Pictures\Wallpaper
;壁纸保存路径设置,不设置时保存到用户的临时目录

 

这个东西网上其实好多人都写过,我主要是烦他们功能太多,或者自定义不够强。

这类东西就是应该有脚本语言写,折腾这个也写了几个小时,看看人家用shell写的多清爽。

https://gist.github.com/atskyline/11146298

 

 

#!/bin/bash
# export DBUS_SESSION_BUS_ADDRESS environment variable useful when the script is set as a cron job
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
# $bing is needed to form the fully qualified URL for
# the Bing pic of the day
bing="www.bing.com"
# $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.
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=1&n=1&mkt=en-US"
# $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
saveDir="$HOME/Poze/BingDesktopImages/"
# Create saveDir if it does not already exist
mkdir -p $saveDir
# Set picture options
# Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="zoom"
# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"
desiredPicRes="_1366x768"
# The file extension for the Bing pic
picExt=".jpg"
# 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 "<urlBase>(.*)</urlBase>" | 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 "<url>(.*)</url>" | 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"
then
# Set picName to the desired picName
picName=${desiredPicURL##*/}
# Download the Bing pic of the day at desired resolution
curl -s -o $saveDir$picName $desiredPicURL
else
# Set picName to the default picName
picName=${defaultPicURL##*/}
# Download the Bing pic of the day at default resolution
curl -s -o $saveDir$picName $defaultPicURL
fi
# Set the GNOME3 wallpaper
gsettings set org.gnome.desktop.background picture-uri "file://$saveDir$picName"
# Set the GNOME 3 wallpaper picture options
gsettings set org.gnome.desktop.background picture-options $picOpts
# Remove pictures older than 30 days
#find $saveDir -atime 30 -delete
# Exit the script
exit
view raw BingWallpaper hosted with ❤ by GitHub

你可能感兴趣的:(bing)