From effe29cd74c07a279341c108e845a5e226d0ec45 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Thu, 3 Oct 2024 19:31:13 +0200 Subject: [PATCH] continue work on ICE tacho --- .../eww/configDir/bottomBar/bottomBar.yuck | 19 +++++-- .../panels/eww/configDir/scripts/iceTacho.nu | 49 ++++++++++++++----- 2 files changed, 51 insertions(+), 17 deletions(-) mode change 100644 => 100755 modules/desktop-environment/home/panels/eww/configDir/scripts/iceTacho.nu diff --git a/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck index cad75ea..611590e 100644 --- a/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck +++ b/modules/desktop-environment/home/panels/eww/configDir/bottomBar/bottomBar.yuck @@ -47,8 +47,19 @@ ) ) -(defpoll iceData - :interval "2s" - :initial "" - `(iw dev wlp4s0 link | grep "WIFIonICE" > /dev/null) && curl https://iceportal.de/api1/rs/status` +(defwidget iceTacho [] + (box + :class "iceTacho" + :tooltip "Tz${iceTachoData.tzn} (BR ${iceTachoData.br})" + (circular-progress + :value { iceTachoData.frac * 60 + 20 } + :thickness 3 + ) + (label :text "${iceTachoData.speed} km/h") + ) +) + +(deflisten iceTachoData + :initial "null" + { "~/.config/eww/scripts/iceTacho.nu" } ) diff --git a/modules/desktop-environment/home/panels/eww/configDir/scripts/iceTacho.nu b/modules/desktop-environment/home/panels/eww/configDir/scripts/iceTacho.nu old mode 100644 new mode 100755 index 0be47c8..fa82321 --- a/modules/desktop-environment/home/panels/eww/configDir/scripts/iceTacho.nu +++ b/modules/desktop-environment/home/panels/eww/configDir/scripts/iceTacho.nu @@ -1,15 +1,38 @@ #!/usr/bin/env nu -const TABLE = [ - [ br vmax ]; - [ 401 280 ] - [ 402 280 ] - [ 403 330 ] - [ 406 330 ] - [ 407 320 ] - [ 408 320 ] - [ 411 230 ] - [ 415 230 ] - [ 412 265 ] - [ 605 200 ] -]; +const TABLE = { + 401: 280 + 402: 280 + 403: 330 + 406: 330 + 407: 320 + 408: 320 + 411: 230 + 415: 230 + 412: 265 + 605: 200 +}; + +def main [ ] { + loop { + if ((iw dev wlp4s0 link | lines | filter {|it| $it =~ "WIFIonICE" } | length) == 1) { + let iceData = http get https://iceportal.de/api1/rs/status; + let tzn = $iceData.tzn; + let br = $iceData.series; + let speed = $iceData.speed; + let speedfrac = $speed / ($TABLE | get $br); + + print ({ + tzn: $tzn, + br: $br, + speed: $speed, + frac: $speedfrac + } | to json -r); + + sleep 2sec; + } else { + print "null"; + sleep 5sec; + } + } +}