Last active
November 8, 2017 22:51
-
-
Save eborden/e7638b958a3ae5165d1f5734becf4f08 to your computer and use it in GitHub Desktop.
Insecure stretching reminder using giphy, jq and systemd timers
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
[Unit] | |
Description=Stretching Reminder | |
[Service] | |
User=username | |
Environment=DISPLAY=:0 | |
Type=oneshot | |
ExecStart=/path-to/stretch.sh |
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/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" |
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
[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