From 2daba173f04ee68db05f0a00f07ba23d78cfc051 Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Sat, 16 Sep 2023 14:56:06 +0100 Subject: [PATCH] Fix for when modem is hotplugged --- blocks-internet | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blocks-internet b/blocks-internet index 1f7bfc1..03e7228 100644 --- a/blocks-internet +++ b/blocks-internet @@ -1 +1,3 @@ -nmcli -t -f active,ssid dev wifi | grep -E 'yes' | cut -c 5- | grep . || (mmcli -m /org/freedesktop/ModemManager1/Modem/0 | grep "operator name:" | cut -c 38- | tr -d '\n' && echo -n ": " && mmcli -m /org/freedesktop/ModemManager1/Modem/0 | grep -P "\d+%" -o) || echo "Disconnected" +modem=$(mmcli -L | grep -P "/org/freedesktop/.+\d" -m 1 -o) + +nmcli -t -f active,ssid dev wifi | grep -E 'yes' | cut -c 5- | grep . || (mmcli -m $modem | grep "operator name:" | cut -c 38- | tr -d '\n' && mmcli -m $modem | grep -P " \d+%" -o) || echo "Disconnected"