Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notification-spacex: migrate from spacexdata to launchlibrary #449

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
notification-spacex: migrate from spacexdata to launchlibrary
api.spacexdata.com is no longer updated
  • Loading branch information
krzys-h committed Sep 24, 2024
commit ff943ce2971c699ae1d9ed0ef6a234c8fe20b277
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
Loading