with import {}; pkgs.writeShellScriptBin "traewelling" '' #!/bin/sh function color() { echo -ne "\e[38;5;$1"m } function j() { jq -r $1 <<< "$json" } user=tudbut if ! [ "$1" = "" ] ; then user="$1" fi if ! [ -e ~/sync/traewelling.token ] ; then exit fi json="$(curl -s -H "Authorization: $(cat ~/sync/traewelling.token)" "https://traewelling.de/api/v1/user/$user/statuses" | jq .data[0])" if [ "$(($(date -d "$(j .train.destination.arrival)" +%s) - $(date +%s) ))" -gt 0 ] ; then color 9 echo "> Traewelling" color 4 echo "In train $(j .train.lineName) to $(j .train.destination.name)" echo "Arrival: in $( date -d "@$(( $(date -d "$(j .train.destination.arrival)" +%s) - $(date +%s) - 60 * 60))" +%H:%M ) at $(j .train.destination.rilIdentifier) $(j .train.destination.arrivalPlatformReal)" echo "bahn.expert: https://bahn.expert/details/$(j .train.lineName | sed -E 's/(.*?) .*/\1/g')%20$(j .train.journeyNumber)" fi ''