Last active
May 6, 2019 08:20
-
-
Save HackingGate/661f9b7221a9b2e27cc6355d93cc8733 to your computer and use it in GitHub Desktop.
Set himawari wallpaper shell script for macOS. (Linux & Windows not tested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH=$PATH:/usr/local/bin | |
echo `date` | |
echo "Checking himawari" | |
if ! type himawari > /dev/null; then | |
echo "Install himawari with:" | |
echo | |
echo "brew install imagemagick" | |
echo "brew install graphicsmagick" | |
echo "npm i himawari -g" | |
echo | |
else | |
mkdir -p /tmp/himawari | |
# Recommended values: 2160p(UHD/4K) use zoom 2; 4320p(8K) use zoom 3; 8640p(16K) use zoom 4; | |
echo "Downloading latest image" | |
himawari --zoom 2 --parallel --timeout 300000 --outfile /tmp/himawari/ | |
fi | |
echo "Checking wallpaper" | |
if ! type wallpaper > /dev/null; then | |
echo "Install wallpaper with:" | |
echo | |
echo "brew install wallpaper" | |
echo | |
else | |
# If download succeeded, $image will be the latest image. | |
image=`find /tmp/himawari/himawari-*.jpg | tail -1` | |
current=`wallpaper get --screen main` | |
change=0 | |
if [[ $current =~ ^/tmp/himawari/himawari-[0-9]*.jpg$ ]]; then | |
# If $current is himawari, update wallpaper without ask user. | |
change=1 | |
else | |
# If $current is not himawari, ask user. | |
echo "Your current wallpaper is $current." | |
read -t 60 -r -p "Do you want to change? [Y/n] " input | |
case $input in | |
[yY][eE][sS]|[yY]) | |
change=1 | |
;; | |
[nN][oO]|[nN]) | |
change=0 | |
;; | |
*) | |
echo "Invalid input..." | |
exit 1 | |
;; | |
esac | |
fi | |
# If download not succeeded, do not change wallpaper. | |
if [[ $change -eq 1 && $image != $current ]]; then | |
wallpaper set $image --screen main --scale fit | |
current=`wallpaper get --screen main` | |
echo "Wallpaper is changed to $current" | |
else | |
echo "Wallpaper is not changed" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
Put
set-himawari-wallpaper.sh
file in~/bin/
Run
~/bin/set-himawari-wallpaper.sh
and answer yesSave the following as
~/Library/LaunchAgents/com.hackinggate.set-himawari-wallpaper.plist
Load as launchctl service
https://alvinalexander.com/mac-os-x/mac-osx-startup-crontab-launchd-jobs
https://stackoverflow.com/a/26586170/4063462