【发布时间】:2021-04-21 20:42:27
【问题描述】:
我有这个脚本来打印一个格式化的字符串,代表我的实际 wifi 连接及其强度:
#! /run/current-system/sw/bin/nix-shell
#! nix-shell -i fish -p fish
set active (ip addr | awk '/state UP/ {print $2}' | sed 's/.$//' | head -n 1)
if test -n $active
set essid (iwconfig $active | awk -F '"' '/ESSID/ {print $2}')
set strength (iwconfig $active | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1)
set bars (expr $strength / 10)
else
echo "No device up"
exit 1
end
switch $bars
case 0
set bars "[----------]"
case 1
set bars "[/---------]"
case 2
set bars "[//--------]"
case 3
set bars "[///-------]"
case 4
set bars "[////------]"
case 5
set bars "[/////-----]"
case 6
set bars "[//////----]"
case 7
set bars "[///////---]"
case 8
set bars "[////////--]"
case 9
set bars "[/////////-]"
case 10
set bars "[//////////]"
case "*"
set bars "[----!!----]"
end
echo $essid $bars
它工作正常,但是我将我的 Linux 发行版更改为 NixOS,其中不推荐使用 iw* 命令,因此我们只有 iw 命令。
在我的搜索中,我发现了这个命令:iw <interface> station dump,它显示了很多信息,但现在正是我需要的。
它没有显示我的实际AP,信号 ios 显示为带负数的 dBm。
如何将旧的iwconfig 命令升级到iw?有可能吗?
【问题讨论】: