Skip to content

Instantly share code, notes, and snippets.

@Nervengift
Last active December 5, 2021 20:16
Show Gist options
  • Save Nervengift/6a49faecfc561297ddfe71f32a1c996c to your computer and use it in GitHub Desktop.
Save Nervengift/6a49faecfc561297ddfe71f32a1c996c to your computer and use it in GitHub Desktop.
statusline for German high speed trains (ICE)
#!/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"
@Nervengift
Copy link
Author

e.g. used with polybar:
20181226112314

@Nervengift
Copy link
Author

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