I wrote a manual wallpaper of Bai Bing's day and changed it to a gnome wallpaper. I still learned a lot.
The next step is to add to the self-starting item at boot, so that it can be automatically updated after booting. I have seen several blogs
Of course, I also wrote a script that can be restored to the default original wallpaper
#!/bin/bash
PICTURE_REPO=~/CNSS/unix_homework/Pictures/bing_wallpapers/
echo "${PICTURE_REPO}"
mkdir -p "${PICTURE_REPO}"
PIC_FILE=$(date +U_Bing_bg_%Y_%m_%d.jpg)
BING_URL="https://www.bing.com"
BING_HTML="BingWeb.html"
# echo "$PIC_URL"
# echo "$PIC_FILE"
wget "${BING_URL}" -O "${BING_HTML}"
PIC_URL=$(grep -Po '(?<=href=")[^"]*jpg[^"]*' ./${BING_HTML})
echo "${PICTURE_REPO}${PIC_FILE}"
echo "Wanna Download picture to this destination?>"
read OPT
case $OPT in
y|yes|YES|Y) ;;
n|no|NO|N) exit 0
;;
esac
wget "${BING_URL}$PIC_URL" -O "${PICTURE_REPO}${PIC_FILE}"
rm -i "$BING_HTML"
if [ -e "orgin_bg" ]; then
echo "orgin_bg has existed"
else
gsettings get org.gnome.desktop.background picture-uri > ./orgin_bg
fi
PIC_DIR="file://${PICTURE_REPO}${PIC_FILE}"
echo $PIC_DIR
echo "Wanna Change ur background?>"
read OPT
case $OPT in
y|yes|YES|Y) ;;
n|no|NO|N) exit 0
;;
esac
gsettings set org.gnome.desktop.background picture-uri "$PIC_DIR"
Here is the script that reverts to the original default desktop
#!/bin/bash
if [ ! -e orgin_bg ]; then
echo "orgin_bg file doesn't exist"
exit 2
fi
ORG_PI=$(cat orgin_bg)
echo "$ORG_PIC"
echo "Wanna recover?[y/n]>"
read OPT
case $OPT in
y|yes|YES|Y) ;;
n|no|NO|N) exit 1
;;
esac
gsettings set org.gnome.desktop.background picture-uri $ORG_PIC