Added ICE polybar module
This commit is contained in:
@@ -51,4 +51,4 @@ bottom = false
|
|||||||
|
|
||||||
modules-left = spotify
|
modules-left = spotify
|
||||||
modules-center = date
|
modules-center = date
|
||||||
modules-right = i3-mode
|
modules-right = ice i3-mode
|
||||||
|
|||||||
@@ -55,3 +55,7 @@ fg = ${colour-scheme.base0C}
|
|||||||
[colours/spotify]
|
[colours/spotify]
|
||||||
bg = ${colour-scheme.base00}
|
bg = ${colour-scheme.base00}
|
||||||
fg = ${colour-scheme.base0A}
|
fg = ${colour-scheme.base0A}
|
||||||
|
|
||||||
|
[colours/ice]
|
||||||
|
bg = ${colour-scheme.base00}
|
||||||
|
fg = ${colour-scheme.base0A}
|
||||||
|
|||||||
8
config/polybar/bars/modules/ice.ini
Normal file
8
config/polybar/bars/modules/ice.ini
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[module/ice]
|
||||||
|
type = custom/script
|
||||||
|
exec = ~/.config/polybar/scripts/ice.sh
|
||||||
|
interval = 5
|
||||||
|
|
||||||
|
format-background = ${colours/ice.bg}
|
||||||
|
format-foreground = ${colours/ice.fg}
|
||||||
|
format-padding = 1
|
||||||
33
config/polybar/scripts/ice.sh
Executable file
33
config/polybar/scripts/ice.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Show current train speed on ICE
|
||||||
|
|
||||||
|
main() {
|
||||||
|
status=$(curl -X GET https://iceportal.de/api1/rs/status 2>/dev/null)
|
||||||
|
tripInfo=$(curl -X GET https://iceportal.de/api1/rs/tripInfo/trip 2>/dev/null)
|
||||||
|
|
||||||
|
if [[ -z $status || -z $tripInfo ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Speed
|
||||||
|
speed=$(echo $status | jq ".speed")
|
||||||
|
|
||||||
|
# Next stop
|
||||||
|
nextId=$(echo $tripInfo | jq ".trip.stopInfo.actualNext")
|
||||||
|
nextStop=$(echo $tripInfo | jq ".trip.stops[] | select( .station.evaNr == $nextId )")
|
||||||
|
|
||||||
|
nextStopName=$(echo $nextStop | jq -r ".station.name")
|
||||||
|
nextStopArrival=$(echo $nextStop | jq ".timetable.actualArrivalTime")
|
||||||
|
|
||||||
|
nextStopRemainingSeconds=$(expr $(expr $nextStopArrival / 1000) - $(date +%s))
|
||||||
|
|
||||||
|
if [[ ${nextStopRemainingSeconds:0:1} == "-" ]]; then
|
||||||
|
nextStopRemainingTime="Arribada!"
|
||||||
|
else
|
||||||
|
nextStopRemainingTime=$(date -d@$nextStopRemainingSeconds -u +%Hh%Mm%Ss)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo " $nextStopName · $nextStopRemainingTime · $speed km/h"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user