shell开机自动换Bing壁纸2.1版
Tofloor
poster avatar
海天鹰
deepin
2018-11-13 00:12
Author
本帖最后由 sonichy 于 2018-12-2 10:35 编辑

2.1:增加通知
2.0:放弃数组分割字符串,直接左割右割拼接,desktop可运行,更简单,可以加入开机启动。
1.0:用数组分割字符串,desktop运行数组报错,只能在终端里运行。

步骤:
1.访问API,获取图片网址,下载,设置壁纸。
bing.sh
URL="https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1"
domain=${URL%/*}
HTML=`mktemp`
wget $URL -O $HTML
var=`cat $HTML`
copyright=${var#*\"copyright\":\"}
copyright=${copyright%%\",*}
#echo $copyright
url=${var#*\"url\":\"}
#echo "删除左边:${url}"
url=${url%%\",*}
#echo "删除右边:${url}"
url=${domain}${url}
#echo "拼接网址:${url}"
wget -q $url -O $HTML
gsettings set org.gnome.desktop.background picture-uri file://$HTML
iconpath=`pwd`/bing.png
#echo $iconpath
notify-send "$copyright" --icon=$iconpath

2.自动生成desktop并加入自动运行:
install.sh
s="[Desktop Entry]\nName=Bing壁纸\nComment=获取Bing壁纸设置为桌面壁纸\nExec=`pwd`/bing.sh\nIcon=`pwd`/bing.png\nPath=`pwd`\nType=Application\nCategories=System;"
echo -e $s > BingWallpaper.desktop
cp `pwd`/BingWallpaper.desktop ~/.config/autostart/BingWallpaper.desktop


Reply Favorite View the author
All Replies
avatar
aida
deepin
2018-11-13 17:38
#1
支持一波!
Reply View the author
avatar
白菜
deepin
2018-11-14 02:36
#2
计划做没空做的东西
Reply View the author
avatar
abc
deepin
2018-11-14 05:14
#3
支持+1,打包成sh文件效果会更好哦。
Reply View the author
avatar
s***1@gmail.com
deepin
2018-11-14 05:21
#4
好玩儿的东西我都喜欢,Mark一下,收下了,多谢
Reply View the author
avatar
cenry9898
deepin
2018-11-14 07:46
#5
赞了      
Reply View the author
avatar
walkinger
deepin
2018-11-16 00:17
#6
好玩儿的东西我都喜欢,Mark一下,收下了,多谢
Reply View the author
avatar
jianguo922
deepin
2018-11-16 00:26
#7
支持一波   
Reply View the author