From 8803eede9937628c7768008b8c1dd8f57024ecb3 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 23 Oct 2023 19:00:46 +0100 Subject: [PATCH] make interval more easily customisably --- keep_trying.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/keep_trying.sh b/keep_trying.sh index 164d524..31422b8 100755 --- a/keep_trying.sh +++ b/keep_trying.sh @@ -1,14 +1,15 @@ #!/bin/sh # simple script to fix my broken wifi -# it checks if wifi is connected every 5 seconds, and if not, repeatedly attempts to connect +# it checks if wifi is connected at regular intervals, and if not, repeatedly attempts to connect network="" interface="" +interval=5 while [ true ]; do - # if wifi is connected, do nothing for 5 seconds + # if wifi is connected, do nothing for $interval seconds if [ -n "$(nmcli connection show | grep '.*'"$network"'.*'"$interface"'.*')" ]; then - sleep 5 + sleep $interval # else, wifi is not connected so attempt to connect to wifi network, and keep trying until it succeeds else nmcli con up "$network" || while [ "$?" != "0" ]; do nmcli con up "$network"; done