Created
January 1, 2025 03:24
-
-
Save echometerain/835f0c5b06476469c99b49af7667b284 to your computer and use it in GitHub Desktop.
Grab the newest xkcd and display it using kitty
This file contains hidden or 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
# assuming you use NetworkManager | |
if [ "$(nmcli networking connectivity check)" != "none" -a ! -z "${KITTY_PID+x}" ]; then | |
XKCD_JSON="$(curl -s https://xkcd.com/info.0.json)" | |
NUM="$(echo $XKCD_JSON | jq -r '.num')" | |
# suppresses error when file does not exist | |
if [ "$(cat ~/.last_xkcd 2>/dev/null)" != "$NUM" ]; then | |
echo $NUM > ~/.last_xkcd | |
echo $XKCD_JSON | jq -r '.safe_title' | |
kitten icat --align left "$(echo $XKCD_JSON | jq -r '.img')" | |
echo $XKCD_JSON | jq -r '.alt' | |
else | |
fortune | |
fi | |
else | |
fortune | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tmux version: