摘要 每日定时自动获取Bing的每日壁纸图片,自动更换登录界面的背景为bing今日美图,并且替换欢迎信息为美图简介。
获取脚本 原始脚本在kkkgo/DSM_Login_BingWallpaper: 群晖登录壁纸自动换 (github.com) ,做了下简单修改,设置为壁纸的图片分辨率为1920x1080,保存的为高清的版本。
下面是修改过的脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 # 设置你的语言 # set your language(en-US,zh-CN...) lang="zh-CN"# 如需收集保存壁纸,请去掉下面注释,设置保存文件夹路径 # 在FileStation里面右键文件夹属性可以看到路径 # If you want to collect and save Wallpapers, # please remove the comment below and set the savepath. # Right click the folder property in FileStation to see the path. savepath="/volume5/Download/BingPicture/wallpaper_uhd"# 如需下载4k分辨率,请设置res=4k # 如需下载体积更大的4k以上分辨率的原始图片,请设置res=raw # To download 4K resolution, set res=4K # To download a larger original picture, set res=raw # res=4k # 修改用户桌面壁纸,注释后会替换系统的wallpaper1 # 你需要清空浏览器缓存查看效果,仅在DSM7.x上测试. # Modify user desktop wallpaper.Only test for DMS7.x. # System "Wallpaper1" will replaced by remove the comment. # You need to clear the browser cache to see the effect. desktop=yes echo "[x]Collecting information..." pic="https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1" if [ "$res" != "" ] then pic="https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&uhd=1&uhdwidth=3840&uhdheight=2160" fi pic=$(wget -t 5 --no-check-certificate -qO- $pic --header="cookie:_EDGE_S=mkt=$lang") echo $pic|grep -q enddate||exit link=$(echo https://www.bing.com$(echo $pic|sed 's/.\+"url"[:" ]\+//g'|sed 's/".\+//g')) if [ "$savepath" != "" ] then linkd=$(echo https://www.bing.com$(echo $pic|sed 's/.\+"url"[:" ]\+//g'|sed 's/".\+//g'|sed 's/1920x1080/UHD/g')) fi date=$(echo $pic|grep -Eo '"enddate":"[0-9]+'|grep -Eo '[0-9]+'|head -1) if [ "$date" == "" ] then date=$(date +%Y%m%d) fi title=$(echo $pic|sed 's/.\+"title":"//g'|sed 's/".\+//g') copyright=$(echo $pic|sed 's/.\+"copyright[:" ]\+//g'|sed 's/".\+//g') keyword=$(echo $copyright|sed 's/, /-/g'|cut -d" " -f1|grep -Eo '[^()\\/:*?"<>]+'|head -1) filename=$date"@"$title"-"$keyword".jpg" echo "Link:"$link echo "Linkd:"$linkd echo "Date:"$date echo "Title:"$title echo "Copyright:"$copyright echo "Keyword:"$keyword echo "Filename:"$filename echo "[x]Downloading wallpaper..." tmpfile=/tmp/$filename wget -t 5 --no-check-certificate $link -qO $tmpfile ls -lah $tmpfile||exit echo "[x]Copying wallpaper..." if [ "$savepath" != "" ] then wget -t 5 --no-check-certificate $linkd -qO $savepath/$filename echo "Save:"$savepath ls -lah "$savepath"|grep $date cd "$savepath" chmod 777 $filename else echo "savepath is not set, skip copy." fi echo "[x]Setting welcome msg..." sed -i s/login_welcome_title=.*//g /etc/synoinfo.conf echo "login_welcome_title=\"$title\"">>/etc/synoinfo.conf sed -i s/login_welcome_msg=.*//g /etc/synoinfo.conf echo "login_welcome_msg=\"$copyright\"">>/etc/synoinfo.conf echo "[x]Applying login wallpaper..." sed -i s/login_background_customize=.*//g /etc/synoinfo.conf echo "login_background_customize=\"yes\"">>/etc/synoinfo.conf sed -i s/login_background_type=.*//g /etc/synoinfo.conf echo "login_background_type=\"fromDS\"">>/etc/synoinfo.conf rm -rf /usr/syno/etc/login_background*.jpg cp -f $tmpfile /usr/syno/etc/login_background.jpg ln -sf /usr/syno/etc/login_background.jpg /usr/syno/etc/login_background_hd.jpg echo "[x]Clean..." rm -f /tmp/bing_*.jpg if [ "$desktop" == "yes" ] then echo "[x]Applying user desktop wallpaper..." mkdir -p /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/ mkdir -p /usr/syno/synoman/webman/resources/images/1x/default_wallpaper/ mkdir -p /usr/syno/synoman/webman/resources/images/default/1x/default_wallpaper/ mkdir -p /usr/syno/synoman/webman/resources/images/default_wallpaper/# 7.0 cp -f /usr/syno/etc/login_background.jpg /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/1x/default_wallpaper/dsm7_01.jpg# 6.0 # ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default/1x/default_wallpaper/default_wallpaper.jpg# ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default/1x/default_wallpaper/dsm6_01.jpg# ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default/1x/default_wallpaper/dsm6_02.jpg# # ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default_wallpaper/default_wallpaper.jpg# # ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default_wallpaper/01.jpg# ln -sf /usr/syno/synoman/webman/resources/images/2x/default_wallpaper/dsm7_01.jpg /usr/syno/synoman/webman/resources/images/default_wallpaper/02.jpg fi
设置定时任务
控制面板-任务计划-新增:
用户账号记得选择root
计划里设置每天跑脚本的时间
任务设置里输入执行脚本的命令
确定就完成任务的设置了,如果想马上看到效果可以选择手动立即执行,然后退出登录账号并Ctrl+F5
刷新浏览器即可看到效果了
可以看到图片也保存到设置的目录了,并且保存下来的是高分辨率的