mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:47:03 +01:00
i3 config was filed under periodic_background, which it never was. It is now linux_configuration/i3/ (config + installer) and linux_configuration/i3blocks/ (the status scripts), both at depth 2. misc/testsAndMisc-bash/ was a directory named after the repo it already lived in, so its contents moved up to misc/. Its stray .gitignore came along, keeping the media rules working from the new location; its .vscode/tasks.json did not, because it invoked Bash/transcribe.sh, a path this repo dropped long ago. Most of this commit is the references the previous flatten missed. Its regex skipped anything with a variable prefix, which left 16 files -- including check_and_enable_services.sh and install_core_system.sh, the orchestrators -- still naming $CONFIG_DIR/scripts/periodic_background/... It had also rewritten three i3 paths into scripts/i3blocks/, a directory that has never existed; the i3blocks suites caught that by failing. 13 more symlinks broke on the i3 move. Repointed, and cpu_monitor/volume/ disk were run again to confirm the bar still reports. Depth 139 -> 104. Roughly 47 of the remainder sit in digital_wellbeing and hosts, still deferred. The rest encode real structure -- a C project, Python package directories, artgate's routes/styles, systemd unit dirs -- so flattening them further would destroy information rather than taxonomy. Verified: 1798 tests at 100%, both i3blocks suites pass, the shell coverage gate is clean, and the relocated media rules still ignore what they should while test_fw.srt stays tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
74 lines
3.9 KiB
Bash
Executable File
74 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# i3blocks efficiency: config wiring, status icons, focus/GPU/ethernet guards.
|
|
# Sourced by test_i3blocks_efficiency.sh; inherits its strict mode and its
|
|
# helpers (fail, assert_equals, assert_le, epoch_utc, count_execs) plus the
|
|
# BIN_DIR / TMP_DIR / CONFIG_FILE / I3BLOCKS_DIR paths it sets up.
|
|
|
|
i3_tests_config_and_guards() {
|
|
printf 'Checking config uses dedicated low-fork scripts...\n'
|
|
grep -q '^command=~/.config/i3blocks/time.sh$' "$CONFIG_FILE" ||
|
|
fail 'time block should call time.sh'
|
|
grep -q '^interval=persist$' "$CONFIG_FILE" ||
|
|
fail 'config should use persist interval for time block'
|
|
grep -q '^command=~/.config/i3blocks/memory.sh$' "$CONFIG_FILE" ||
|
|
fail 'memory block should call memory.sh'
|
|
grep -q '^command=~/.config/i3blocks/ethernet.sh$' "$CONFIG_FILE" ||
|
|
fail 'ethernet block should call ethernet.sh'
|
|
grep -q '^command=~/.config/i3blocks/disk.sh$' "$CONFIG_FILE" ||
|
|
fail 'disk block should call disk.sh'
|
|
grep -q '^interval=10$' "$CONFIG_FILE" ||
|
|
fail 'cpu block should poll at 10s interval'
|
|
grep -A2 '^\[motherboard_temperature\]$' "$CONFIG_FILE" | grep -q '^interval=30$' ||
|
|
fail 'motherboard block should poll at 30s interval'
|
|
grep -A2 '^\[memory\]$' "$CONFIG_FILE" | grep -q '^interval=30$' ||
|
|
fail 'memory block should poll at 30s interval'
|
|
grep -A2 '^\[ethernet\]$' "$CONFIG_FILE" | grep -q '^interval=persist$' ||
|
|
fail 'ethernet block should use persist mode'
|
|
grep -A2 '^\[claude_usage\]$' "$CONFIG_FILE" | grep -q '^interval=60$' ||
|
|
fail 'claude_usage block should poll at 60s interval'
|
|
grep -q '^command=~/.config/i3blocks/claude_usage.sh$' "$CONFIG_FILE" ||
|
|
fail 'claude_usage block should call claude_usage.sh'
|
|
|
|
# Blocks for hardware/software absent from this machine were removed; make sure
|
|
# they do not silently return. Each rendered permanently-dead text in the bar.
|
|
for removed_block in bluetooth battery wifi activitywatch warp network_monitor; do
|
|
if grep -q "^\[${removed_block}\]$" "$CONFIG_FILE"; then
|
|
fail "removed block [${removed_block}] should not be in the config"
|
|
fi
|
|
done
|
|
|
|
printf 'Checking status icons avoid Font Awesome private-use codepoints...\n'
|
|
# The fonts named in the i3 bar's pango string are not installed, so private-use
|
|
# codepoints (U+E000-U+F8FF) fall through to whatever font claims them - which
|
|
# rendered the ethernet icon as a star and the wifi icon as Cyrillic. Plain
|
|
# Unicode/emoji resolve consistently instead.
|
|
for icon_script in "$I3BLOCKS_DIR"/*.sh; do
|
|
if grep -qP '[\x{E000}-\x{F8FF}]|\\u[eEfF][0-9a-fA-F]{3}' "$icon_script"; then
|
|
fail "$(basename "$icon_script") should not use private-use-area icon codepoints"
|
|
fi
|
|
done
|
|
|
|
printf 'Checking focus detection path avoids extra xdotool lookups...\n'
|
|
! grep -Fq "xdotool getwindowname \"\$wid\"" "$REPO_DIR/lib/common.sh" ||
|
|
fail 'focus detection should not call xdotool getwindowname in hot path'
|
|
|
|
printf 'Checking GPU dedupe guards exist...\n'
|
|
grep -Fq 'emit_if_changed()' "$I3BLOCKS_DIR/gpu_monitor.sh" ||
|
|
fail 'gpu monitor should dedupe repeated identical samples'
|
|
grep -Fq "source \"\$SCRIPT_DIR/persist_common.sh\"" "$I3BLOCKS_DIR/ethernet.sh" ||
|
|
fail 'ethernet script should use shared persist helper'
|
|
grep -Fq "source \"\$SCRIPT_DIR/persist_common.sh\"" "$I3BLOCKS_DIR/gpu_monitor.sh" ||
|
|
fail 'gpu script should use shared persist helper'
|
|
grep -Fq 'i3blocks_update_if_changed_key "ethernet_output"' "$I3BLOCKS_DIR/ethernet.sh" ||
|
|
fail 'ethernet script should dedupe unchanged output'
|
|
|
|
printf 'Checking ethernet picks a physical NIC over virtual bridges...\n'
|
|
# Regression: the old loop returned the first non-loopback interface, which on a
|
|
# machine with docker installed is a `br-*` bridge (always "down", and sorted
|
|
# before enp*/eth*), so the bar reported "down" on a live wired connection.
|
|
grep -Fq 'iface_path}/device' "$I3BLOCKS_DIR/ethernet.sh" ||
|
|
fail 'ethernet script should require a real device to skip virtual interfaces'
|
|
|
|
return 0
|
|
}
|