Skip to content

Commit

Permalink
notification-spacex: migrate from spacexdata to launchlibrary (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzys-h authored Sep 24, 2024
1 parent 8a6a2c7 commit dd3dfa2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions polybar-scripts/notification-spacex/notification-spacex.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/sh

spacex_launch=$(curl -sf https://api.spacexdata.com/v5/launches/next)
spacex_launch=$(curl -sf "https://ll.thespacedevs.com/2.2.0/launch/upcoming/?lsp__name=SpaceX&status__ids=1&limit=1")

if [ -n "$spacex_launch" ]; then
spacex_precision=$(echo "$spacex_launch" | jq -r '.date_precision' )
spacex_timestamp=$(echo "$spacex_launch" | jq -r '.date_unix' )
spacex_precision=$(printf "%s" "$spacex_launch" | jq -r '.results[0].net_precision.abbrev' )
spacex_timestamp=$(date +"%s" --date "$(printf "%s" "$spacex_launch" | jq -r '.results[0].net' )")
spacex_duration=$((spacex_timestamp - $(date +%s)))

if [ "$spacex_precision" = "hour" ] && [ "$spacex_duration" -lt 43200 ] && [ "$spacex_duration" -gt 0 ]; then
echo "# $(date +"%H:%M" -u --date @$spacex_duration)"
if [ "$spacex_precision" = "HR" ] || [ "$spacex_precision" = "MIN" ] || [ "$spacex_precision" = "SEC" ]; then
if [ "$spacex_duration" -lt 43200 ] && [ "$spacex_duration" -gt 0 ]; then
echo "# $(date +"%H:%M" -u --date @$spacex_duration)"
else
echo ""
fi
else
echo ""
fi
Expand Down

0 comments on commit dd3dfa2

Please sign in to comment.