From 3e1407c30b9702e7d24bbef48527337fba8acf1e Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 19 Dec 2022 00:29:48 +0000 Subject: [PATCH] new script to reconnect to best wifi network --- pkgs/sane-scripts/default.nix | 2 ++ pkgs/sane-scripts/src/sane-ip-reconnect | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 pkgs/sane-scripts/src/sane-ip-reconnect diff --git a/pkgs/sane-scripts/default.nix b/pkgs/sane-scripts/default.nix index e3a052b3..4e2dbeb1 100644 --- a/pkgs/sane-scripts/default.nix +++ b/pkgs/sane-scripts/default.nix @@ -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" diff --git a/pkgs/sane-scripts/src/sane-ip-reconnect b/pkgs/sane-scripts/src/sane-ip-reconnect new file mode 100755 index 00000000..ab422f47 --- /dev/null +++ b/pkgs/sane-scripts/src/sane-ip-reconnect @@ -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"