This commit is contained in:
2024-02-27 02:25:37 +01:00
parent 67a44a5ff8
commit 6d92c68425
14 changed files with 265 additions and 89 deletions

26
waybar/scripts/fsmi.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: fsmi.sh <fsi|fsm>"
exit 1
fi
if [[ "$1" == "fsi" ]]; then
state=$(curl https://www-test.fsmi.org/spaceapi/fsi.json 2>/dev/null | jq .state.open)
elif [[ "$1" == "fsm" ]]; then
state=$(curl https://www-test.fsmi.org/spaceapi/fsm.json 2>/dev/null | jq .state.open)
fi
class="fs-closed"
if [[ "$state" == "true" ]]; then
class="fs-open"
elif [[ "$state" == "" ]]; then
class="fs-unknown"
fi
cat <<EOF | jq -r --unbuffered --compact-output
{
"text": "$state",
"alt": "$1",
"class": "$class"
}
EOF

View File

@ -13,10 +13,10 @@ print_train_info() {
wifionice_conn=$( echo "$wifionice" | jq -r .connectivity.currentState )
wifionice_nextConn=$( echo "$wifionice" | jq -r .connectivity.nextState )
wifionice_connTime=$( echo "$wifionice" | jq -r .connectivity.remainingTimeSeconds | awk '{printf "%d m", $1/60}' )
if [ "$wifionice_speed" -ne 0 ]; then
wifionice_speed=" - $wifionice_speed km/h"
else
if [ "$wifionice_speed" = "0" ]; then
wifionice_speed=""
else
wifionice_speed=" $wifionice_speed km/h"
fi
station=$(curl -sLf https://iceportal.de/api1/rs/tripInfo/trip | jq '[.[].stops[]? | select(.info.passed == false)][0]')
@ -41,7 +41,7 @@ print_train_info() {
net_text="Net: $wifionice_conn$wifionice_nextConn ($wifionice_connTime)"
fi
echo "$icon $station_arrival$station_delay - $station_name, Gl. $station_track$wifionice_speed | $net_text"
echo "$icon $station_arrival$station_delay - $station_name, Gl. $station_track$wifionice_speed"
fi
sleep 10
else