From b7dfa5fdb2330f1e1cd222365055c3d45ad473be Mon Sep 17 00:00:00 2001 From: Rose Date: Fri, 10 Oct 2025 11:29:10 +0200 Subject: all: Rework system structure --- desktop/Local/share/barmodules/ice.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 desktop/Local/share/barmodules/ice.sh (limited to 'desktop/Local/share/barmodules/ice.sh') 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" -- cgit v1.2.3