traewelling: add token support

This commit is contained in:
Daniella / Tove 2024-10-22 18:31:32 +02:00
parent 5e0acac0bb
commit 5202f6ed39
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -14,8 +14,12 @@ pkgs.writeShellScriptBin "traewelling" ''
if ! [ "$1" = "" ] ; then
user="$1"
fi
if ! [ -e ~/sync/traewelling.token ] ; then
exit
fi
json="$(curl -s "https://traewelling.de/api/v1/user/$user/statuses" | jq .data[0])"
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"