Skip to content

Commit ba8ee26

Browse files
🩹 fix(wifi.noise): Upgrade integrations.
1 parent 9727635 commit ba8ee26

File tree

10 files changed

+259
-86
lines changed

10 files changed

+259
-86
lines changed

.bin/bun/bun.lock

Lines changed: 130 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env -S bun run
2+
3+
import fs from 'node:fs';
4+
import process from 'node:process';
5+
6+
import blessed from 'blessed';
7+
import contrib from 'blessed-contrib';
8+
9+
const chart = process.argv[2];
10+
const source = process.argv[3];
11+
12+
const blob = fs.readFileSync(source).toString();
13+
14+
const json = JSON.parse(blob);
15+
const data = json.data;
16+
const options = json.options;
17+
18+
console.error(chart, data, options);
19+
20+
const screen = blessed.screen();
21+
22+
const widget = contrib[chart](options);
23+
24+
screen.append(widget) //must append before setting data
25+
26+
widget.setData(data);
27+
28+
screen.key(['C-c'], function(ch, key) {
29+
return process.exit(0);
30+
});
31+
32+
screen.render();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"private": true,
3+
"name": "__chart",
4+
"version": "0.0.1",
5+
"type": "module",
6+
"dependencies": {
7+
"blessed": "^0.1.81",
8+
"blessed-contrib": "^4.11.0"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^24.2.0",
12+
"typescript": "^5.9.2"
13+
}
14+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"target": "esnext",
6+
"module": "esnext",
7+
"lib": ["esnext"],
8+
"allowJs": true,
9+
"checkJs": true,
10+
"incremental": true,
11+
12+
"strict": true,
13+
"noImplicitAny": false,
14+
"noImplicitThis": false,
15+
"strictNullChecks": true,
16+
17+
"noImplicitReturns": true,
18+
"noFallthroughCasesInSwitch": true,
19+
"noImplicitOverride": false,
20+
"noPropertyAccessFromIndexSignature": false,
21+
"noUncheckedIndexedAccess": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
25+
"allowUnreachableCode": false,
26+
27+
"moduleResolution": "node",
28+
"resolveJsonModule": true,
29+
"esModuleInterop": true,
30+
"preserveSymlinks": true,
31+
"allowSyntheticDefaultImports": true
32+
}
33+
}

.bin/chart

Lines changed: 0 additions & 30 deletions
This file was deleted.

.bin/chart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bun/dist/chart/bin/chart.js

.bin/wifi.endpoints._list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env sh
22

3-
iwlist "$1" scanning | grep -E 'Cell |Frequency|ESSID|Quality'
3+
iwlist "$1" scanning | grep -E 'Cell |Channel|Frequency|ESSID|Quality'

.bin/wifi.endpoints._list.format

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,53 @@
22

33
import sys
44
import json
5-
6-
7-
def by(n, iterable):
8-
9-
iterator = iter(iterable)
10-
11-
group = None
12-
13-
try:
14-
15-
while True:
16-
17-
group = []
18-
19-
while len(group) < n:
20-
21-
group.append(next(iterator))
22-
23-
yield group
24-
25-
except StopIteration:
26-
27-
if group:
28-
yield group
5+
from typing import Iterable
6+
from dataclasses import dataclass, asdict
7+
8+
@dataclass
9+
class Cell:
10+
address: str|None = None
11+
channel: int|None = None
12+
frequency: float|None = None
13+
quality: float|None = None
14+
signal: int|None = None
15+
essid: str = ""
16+
17+
18+
def cells(iterable: Iterable[str]):
19+
20+
cell = None
21+
22+
for line in iterable:
23+
if line.startswith('Cell '):
24+
if cell is not None:
25+
yield cell
26+
cell = Cell(
27+
address = line.split(': ')[1]
28+
)
29+
continue
30+
31+
assert cell is not None
32+
33+
if line.startswith('Frequency:'):
34+
cell.frequency = float(line.split(':')[1].split(' ')[0])
35+
elif line.startswith('Channel:'):
36+
cell.channel = int(line.split(':')[1])
37+
elif line.startswith('ESSID:'):
38+
if cell.essid == "":
39+
cell.essid = line.split(':')[1][1:-1]
40+
elif line.startswith('Quality='):
41+
_quality, _signal = line.split(' ')
42+
value, maximum = _quality.split('=')[1].split('/')
43+
cell.quality = int(value) / int(maximum)
44+
cell.signal = int(_signal.split('=')[1].split(' ')[0])
45+
46+
if cell is not None:
47+
yield cell
2948

3049
data = []
3150

32-
for _cell in by(4, map(str.strip, sys.stdin)):
33-
34-
_address, _frequency, _strength, _ESSID = _cell
35-
36-
address = _address.split(': ')[1]
37-
38-
_tmp = _frequency.split(':')[1].split(' (')
39-
channel = int(_tmp[1].split(' ')[1].split(')')[0])
40-
frequency = float(_tmp[0].split(' ')[0])
41-
_quality, _signal = _strength.split(' ')
42-
value, maximum = _quality.split('=')[1].split('/')
43-
quality = int(value) / int(maximum)
44-
signal = int(_signal.split('=')[1].split(' ')[0])
45-
46-
47-
ESSID = _ESSID[7:-1]
48-
49-
cell = {
50-
"ESSID": ESSID,
51-
"address": address,
52-
"channel": channel,
53-
"frequency": frequency,
54-
"quality": quality,
55-
"signal": signal,
56-
}
57-
58-
data.append(cell)
51+
for cell in cells(map(str.strip, sys.stdin)):
52+
data.append(asdict(cell))
5953

6054
json.dump(data, sys.stdout)

.bin/wifi.noise

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ IGNORE="$1"
66

77
DEVICE="$2"
88

9-
sudo wifi.endpoints.scan "$DEVICE"
9+
wifi.endpoints.scan "$DEVICE"
1010

1111
wifi.endpoints "$DEVICE" | \
1212
jq 'map(select([.address] | inside(['"$IGNORE"']) | not))' | \

bootstrap/obsolete/node

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ eslint-plugin-babel # deprecated
2121
npx # deprecated
2222
tick # use node --prof-process instead
2323
xo # use npx xo
24+
blessed # moved to .bin/node_modules/chart
25+
blessed-contrib # moved to .bin/node_modules/chart

0 commit comments

Comments
 (0)