new script to reconnect to best wifi network

This commit is contained in:
colin 2022-12-19 00:29:48 +00:00
parent 0a744117a4
commit 3e1407c30b
2 changed files with 14 additions and 0 deletions

View File

@ -29,6 +29,7 @@ resholve.mkDerivation {
ifuse
inetutils
inotify-tools
iwd
ncurses
oath-toolkit
openssh
@ -66,6 +67,7 @@ resholve.mkDerivation {
"cannot:${duplicity}/bin/duplicity"
"cannot:${gocryptfs}/bin/gocryptfs"
"cannot:${ifuse}/bin/ifuse"
"cannot:${iwd}/bin/iwctl"
"cannot:${oath-toolkit}/bin/oathtool"
"cannot:${openssh}/bin/ssh-keygen"
"cannot:${rmlint}/bin/rmlint"

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# reconnect to best wifi network.
# lappy frequently DCs from the ideal network
set -ex
sudo iwctl station wlan0 scan
sleep 5
# get networks. remove control characters (colors), then leading info, then take the top-rated network
netname=$(iwctl station wlan0 get-networks | sed 's/\[[0-9;]*m//g' | sed 's/^ [ >]*//g' | sed -n 5p | cut -d' ' -f 1)
sudo iwctl station wlan0 connect "$netname"