diff options
author | Rose Hellsing <rose@pinkro.se> | 2025-10-03 16:44:47 +0200 |
---|---|---|
committer | Rose Hellsing <rose@pinkro.se> | 2025-10-03 10:48:58 -0400 |
commit | 1ad339ccc5b00d95634266691066e1ab1cfd2dd7 (patch) | |
tree | bcb406f29f64c8dbf21d7fb87ad52dffd391c547 /desktop/.local | |
parent | 225ff80ee174949958f03a02cd7bdee66b65245f (diff) | |
download | dotfiles-1ad339ccc5b00d95634266691066e1ab1cfd2dd7.tar.gz dotfiles-1ad339ccc5b00d95634266691066e1ab1cfd2dd7.tar.bz2 |
desktop: Add ice barmodule
Diffstat (limited to 'desktop/.local')
-rwxr-xr-x | desktop/.local/share/barmodules/ice.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/desktop/.local/share/barmodules/ice.sh b/desktop/.local/share/barmodules/ice.sh new file mode 100755 index 0000000..ae04fcc --- /dev/null +++ b/desktop/.local/share/barmodules/ice.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +iceStatus=$(curl https://iceportal.de/api1/rs/status 2>/dev/null) +iceTrip=$(curl https://iceportal.de/api1/rs/tripInfo/trip 2> /dev/null) + +nextStopID=$(echo ${iceTrip} | jq -r .trip.stopInfo.actualNext) +nextStopObject=$(echo ${iceTrip} | jq -c ".trip.stops | map(select(.station.evaNr == \"${nextStopID}\"))") + +scheduledArrival=$(echo ${nextStopObject} | jq -r ".[0].timetable.scheduledDepartureTime/1000") +actualArrival=$(echo ${nextStopObject} | jq -r ".[0].timetable.actualArrivalTime/1000") +arrivalDelay=$(echo ${nextStopObject} | jq -r ".[0].timetable.arrivalDelay") + +trainDistanceSinceStop=$(echo ${iceTrip} | jq -r ".trip.distanceFromLastStop") +nextStopDistance=$(echo ${nextStopObject} | jq -r "(.[0].info.distance-${trainDistanceSinceStop})/1000") + + +echo -n "ICE $(echo ${iceTrip} | jq -r '.trip.vzn'): " +echo -n "Speed: $(echo ${iceStatus} | jq -r '.speed')km/h; " +echo -n "Next Stop: $(echo ${nextStopObject} | jq -r '.[0].station.name') " +echo -n $(date --date="@${actualArrival}" +"%H:%M")" (${arrivalDelay}) " +echo -n "${nextStopDistance}km" |