Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
shell开机自动换Bing壁纸2.1版
Apps Section
660
views ·
7
replies ·
To
floor
Go
海天鹰
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
Like 0
Favorite
View the author
All Replies
aida
deepin
2018-11-13 17:38
#1
支持一波!
Reply
Like 0
View the author
白菜
deepin
2018-11-14 02:36
#2
计划做没空做的东西
Reply
Like 0
View the author
abc
deepin
2018-11-14 05:14
#3
支持+1,打包成sh文件效果会更好哦。
Reply
Like 0
View the author
s***1@gmail.com
deepin
2018-11-14 05:21
#4
好玩儿的东西我都喜欢,Mark一下,收下了,多谢
Reply
Like 0
View the author
cenry9898
deepin
2018-11-14 07:46
#5
赞了
Reply
Like 0
View the author
walkinger
deepin
2018-11-16 00:17
#6
好玩儿的东西我都喜欢,Mark一下,收下了,多谢
Reply
Like 0
View the author
jianguo922
deepin
2018-11-16 00:26
#7
支持一波
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Update driver for my computer
Popular Events
More
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