From 33223c84c3cd0d45a934941ede1ae157648487e7 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Wed, 21 Jun 2023 14:27:23 +0200 Subject: [PATCH] added: dmenu connect script --- dmenu_scripts/dmenu_connect.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 dmenu_scripts/dmenu_connect.sh diff --git a/dmenu_scripts/dmenu_connect.sh b/dmenu_scripts/dmenu_connect.sh new file mode 100755 index 0000000..6294fa7 --- /dev/null +++ b/dmenu_scripts/dmenu_connect.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Retrieve saved network names from wpa_supplicant +networks=$(wpa_cli -i wlan0 list_networks | awk '{print $2}') + +# Display network names using dmenu and store the selected network +selected_network=$(echo "$networks" | dmenu -p "Select a network:") + +# Get network ID from network name +network_id=$(wpa_cli -i wlan0 list_networks | grep $selected_network | awk '{print $1}') + +# Check if a network was selected +if [ -n "$network_id" ]; then + # Connect to the selected network using wpa_supplicant + wpa_cli -i wlan0 select_network "$network_id" + echo "Connecting to $selected_network..." +fi +