Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint Python
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8

- name: Check formatting with black
run: black --check --verbose --line-length 79 bin/bin/tsd-plot.py src/tsd_plot tests python

- name: Lint with flake8
run: |
flake8 --tee --output-file flake8.report bin/bin/tsd-plot.py src/tsd_plot tests python

- name: Upload flake8 report
if: always()
uses: actions/upload-artifact@v4
with:
name: flake8-report
path: flake8.report

tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest

- name: Run pytest
run: pytest
46 changes: 39 additions & 7 deletions bin/bin/speedtest
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ tmp_json=$(mktemp -t speedtest_json_XXXXXX)
cleanup() { rm -f "$tmp_json"; }
trap cleanup EXIT

detect_default_interface() {
local output line
if ! output=$(ip route show default 2>/dev/null); then
return
fi
while IFS= read -r line; do
[[ $line == default* ]] || continue
read -ra parts <<<"$line"
for idx in "${!parts[@]}"; do
if [[ ${parts[$idx]} == "dev" ]] && (( idx + 1 < ${#parts[@]} )); then
echo "${parts[$((idx + 1))]}"
return
fi
done
done <<<"$output"
}

detect_wifi_ssid() {
local interface=$1
if command -v iwgetid >/dev/null 2>&1; then
iwgetid "$interface" --raw 2>>/tmp/iwgetid.log | head -n1
fi
}

# Run speedtest -> JSON
if ! "$SPEEDTEST_BIN" -f json >"$tmp_json" 2>/dev/null; then
# Fall back to invocation time only if we must
Expand Down Expand Up @@ -74,14 +98,22 @@ record_value "$epoch_ts" "$ping_ms" ping
record_value "$epoch_ts" "$dl_MiBps" download
record_value "$epoch_ts" "$ul_MiBps" upload

# SSID (if on Wi-Fi; ignore errors)
if command -v iwgetid >/dev/null 2>&1; then
ssid=$(iwgetid -r 2>>/tmp/iwgetid.log || true)
ssid=${ssid:-unknown-ssid}
record_value "$epoch_ts" "$ssid" ssid
else
record_value "$epoch_ts" "$interface_name" ssid
# Determine current network identifier (SSID if wifi, else interface name)
network_id="unknown"
default_iface=$(detect_default_interface)
if [[ -n "${default_iface:-}" ]]; then
ssid=$(detect_wifi_ssid "$default_iface" || true)
if [[ -n "${ssid:-}" ]]; then
network_id="$ssid"
else
network_id="$default_iface"
fi
elif [[ -n "${interface_name:-}" ]]; then
# Fall back to interface reported by speedtest JSON
network_id="$interface_name"
fi

record_value "$epoch_ts" "$network_id" ssid


exit 0
4 changes: 2 additions & 2 deletions i3/i3/i3status.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

general {
colors = true
interval = 5
interval = 1
}

#order += "ipv6"
Expand Down Expand Up @@ -61,7 +61,7 @@ read_file network_status {
format = "%content"
#format_bad = "%title - %errno: %error"
format_bad = ""
path = "/home/jeff/.uptime-status"
path = "/home/jeff/.network-status"
# Max_characters = 255
}

Expand Down
Loading