Skip to content

Commit dd3dfa2

Browse files
authored
notification-spacex: migrate from spacexdata to launchlibrary (#449)
1 parent 8a6a2c7 commit dd3dfa2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

polybar-scripts/notification-spacex/notification-spacex.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#!/bin/sh
22

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

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

10-
if [ "$spacex_precision" = "hour" ] && [ "$spacex_duration" -lt 43200 ] && [ "$spacex_duration" -gt 0 ]; then
11-
echo "# $(date +"%H:%M" -u --date @$spacex_duration)"
10+
if [ "$spacex_precision" = "HR" ] || [ "$spacex_precision" = "MIN" ] || [ "$spacex_precision" = "SEC" ]; then
11+
if [ "$spacex_duration" -lt 43200 ] && [ "$spacex_duration" -gt 0 ]; then
12+
echo "# $(date +"%H:%M" -u --date @$spacex_duration)"
13+
else
14+
echo ""
15+
fi
1216
else
1317
echo ""
1418
fi

0 commit comments

Comments
 (0)