From dd3dfa2d76f095b6bbb4c8afaa4f16bee83c0e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ha=C5=82adyn=20=28krzys=5Fh=29?= Date: Tue, 24 Sep 2024 22:23:16 +0200 Subject: [PATCH] notification-spacex: migrate from spacexdata to launchlibrary (#449) --- .../notification-spacex/notification-spacex.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/polybar-scripts/notification-spacex/notification-spacex.sh b/polybar-scripts/notification-spacex/notification-spacex.sh index 2337a4ff..854c4cdd 100644 --- a/polybar-scripts/notification-spacex/notification-spacex.sh +++ b/polybar-scripts/notification-spacex/notification-spacex.sh @@ -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