sh random-wallpaper.sh
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh random-wallpaper.sh相关的知识,希望对你有一定的参考价值。
#!/bin/bash
set -e
DIR=$(pwd)
RESOLUTION=AUTO
DATE=$(date +%Y%m%d)
OUTPUT=yandeximage-$DATE.jpg
if [[ $OSTYPE != darwin* ]]; then
echo "macOS only"
exit 1
fi
if [[ $RESOLUTION == AUTO ]]; then
RESOLUTION=$(system_profiler SPDisplaysDataType | grep Resolution \
| sed -E 's/[^0-9]*([0-9]+) x ([0-9]+).*/\1x\2/')
echo "Found display resolution: $RESOLUTION"
fi
if [[ ! -f $OUTPUT ]]; then
echo "Downloading image"
curl https://yandex.ru/images/today?size=$RESOLUTION -o $OUTPUT
fi
echo "Setting background"
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$DIR/$OUTPUT\""
echo "Done"
exit 0
以上是关于sh random-wallpaper.sh的主要内容,如果未能解决你的问题,请参考以下文章