Skip to content

Instantly share code, notes, and snippets.

@emersion
Last active July 27, 2017 09:25
Show Gist options
  • Save emersion/c2faba1f2aba5ba7509b4c74fcb95e71 to your computer and use it in GitHub Desktop.
Save emersion/c2faba1f2aba5ba7509b4c74fcb95e71 to your computer and use it in GitHub Desktop.
background-rotate
makise_kurisu rating:s width:>1000 height:>900
#!/usr/bin/bash
set -euf -o pipefail
tag=$(cat ~/.background-tags | tr '\n' ' ')
url=$(curl 'https://yande.re/post.json' -G --data-urlencode "tags=$tag order:random limit:1" | jq -r '.[0].file_url')
curl -o ~/.background "$url"
[Unit]
Description=Rotate background image
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=%h/bin/background-rotate
Restart=on-failure
RestartSec=30
[Unit]
Description=Rotate background image
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment