Last active
December 5, 2021 20:16
-
-
Save Nervengift/6a49faecfc561297ddfe71f32a1c996c to your computer and use it in GitHub Desktop.
statusline for German high speed trains (ICE)
This file contains 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
#!/bin/bash | |
set -e | |
tripInfo=$(curl -s https://iceportal.de/api1/rs/tripInfo/trip|jq '.trip') | |
status=$(curl -s https://iceportal.de/api1/rs/status) | |
next=$(echo $tripInfo|jq '.stopInfo.actualNext as $next|.stops[]|select(.station.evaNr == $next)') | |
if [ -z "$next" ]; then | |
echo "Endstation" | |
exit 0 | |
fi | |
nextArrivalTs=$(echo $next|jq '.timetable.actualArrivalTime/1000') | |
nextArrival=$(date -d "@$nextArrivalTs" +%H:%M) | |
delay=$(echo $next|jq '.timetable.arrivalDelay' -r) | |
nextStation=$(echo $next|jq '.station.name' -r) | |
speed=$(echo $status|jq '.speed') | |
if [ -n "$delay" ]; then | |
delay=" ($delay)" | |
fi | |
echo "$speed km/h > $nextStation $nextArrival$delay" |
If anyone is following this: I updated the API URL to make it work again
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g. used with polybar: