From a3b254cc3e0d3ed4fe9f1336a81e3ffaee100fbc Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Wed, 21 Jun 2023 15:14:31 +0200 Subject: [PATCH] Improve resource usage This optimized version makes use of the get_network command in wpa_cli to directly retrieve the network ID of the selected network. This eliminates the need for additional stream processing by avoiding grep and awk. --- dmenu_scripts/wpa_connect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmenu_scripts/wpa_connect b/dmenu_scripts/wpa_connect index c322244..474eda4 100755 --- a/dmenu_scripts/wpa_connect +++ b/dmenu_scripts/wpa_connect @@ -10,7 +10,7 @@ networks=$(wpa_cli -i $nic_name list_networks | awk '{print $2}' | tail -n +2) selected_network=$(echo "$networks" | dmenu -p "Select a network:") # Get network ID from network name -network_id=$(wpa_cli -i $nic_name list_networks | grep $selected_network | awk '{print $1}') +network_id=$(wpa_cli -i "$nic_name" get_network "$selected_network" id) # Check if a network was selected if [ -n "$network_id" ]; then