Skip to content

Instantly share code, notes, and snippets.

@eborden
Last active November 8, 2017 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eborden/e7638b958a3ae5165d1f5734becf4f08 to your computer and use it in GitHub Desktop.
Save eborden/e7638b958a3ae5165d1f5734becf4f08 to your computer and use it in GitHub Desktop.
Insecure stretching reminder using giphy, jq and systemd timers
[Unit]
Description=Stretching Reminder
[Service]
User=username
Environment=DISPLAY=:0
Type=oneshot
ExecStart=/path-to/stretch.sh
#! /bin/sh
echo "Starting Stretch Reminder"
API_KEY='Giphy-Api-Key'
echo "Querying Giphy"
JSON=$(curl "https://api.giphy.com/v1/gifs/random?tag=stretch&fmt=json&api_key=$API_KEY")
echo "Parsing JSON"
GIF_URL=$(echo "$JSON" | jq -r '.data.image_original_url')
echo "Download file"
TEMP_FILE="$(mktemp -u).gif"
wget "$GIF_URL" -O "$TEMP_FILE"
echo "Opening gif: $TEMP_FILE"
eog "$TEMP_FILE"; rm "$TEMP_FILE"
[Unit]
Description=Stretching Reminder Timer
[Timer]
OnUnitActiveSec=1h
OnBootSec=1h
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment