如果搜索出来的连接不能用,把连接中间的日期去掉就好了,最近更改了所有连接的名字

xfce4自动更新bing壁纸脚本

archlinux huahua 896℃

需要使用curl,wget,和jq,代码在这里

#!/bin/bash
#sleep 15
current_date=`date +%Y%m%d`
#downpath
downpath=/home/ivo/Pictures/BingPics/cn.bing.com/az/hprichbg/rb/
if [ ! -d "$downpath" ];then
    mkdir -p $downpath
fi

cd $downpath
netstat=$(ping -c3 g.cn|grep transmitted |awk '{print $4}')
if [ $netstat == 0 ]
then
    echo "/home/ivo/script/wallpapper.sh"|at "now +5 minutes"
    #tmptime=ls |grep
        elif [ `ls|grep $current_date|wc -l` == 0 ]
        then
        # use http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US get base_url
        base_url=`curl -s 'http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN'|jq .images[0].url|awk '{print $1}'|sed 's/"//g'`
        #use_url=`echo $base_url |awk '{print $1}'|sed 's/"//g'`
        head_url="http://cn.bing.com"
        original_url=$head_url$base_url
        #get Pictures_name
        Pictures_name=`echo $original_url|awk -F\/ '{print $NF}'`
        #download
        wget -c $original_url
        fs=_
        mv $Pictures_name $current_date$fs$Pictures_name
        # Set the GNOME3 wallpaper
        xfconf-query -c  xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s  $downpath$current_date$fs$Pictures_name
fi

转载请注明:EZLOST » xfce4自动更新bing壁纸脚本

喜欢 (0)