aboutsummaryrefslogtreecommitdiff
path: root/home/rices/schrottkatze/eww/configDir/scripts/iceTacho.nu
blob: 5225dc209929ff7e3ced06e182596d192540d519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env nu

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;
    }
  }
}