Compare commits
3 Commits
45da074144
...
2257c79bc2
Author | SHA1 | Date |
---|---|---|
Filip Rojek | 2257c79bc2 | 1 year ago |
Filip Rojek | 66de81c07b | 1 year ago |
Filip Rojek | 0aa4d73ef0 | 1 year ago |
@ -1,18 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get network interface card name
|
||||||
|
nic_name=$(ip link show | awk -F': ' '/^[0-9]+: (wlan|wlp)/ {print $2; exit}')
|
||||||
|
|
||||||
# Retrieve saved network names from wpa_supplicant
|
# Retrieve saved network names from wpa_supplicant
|
||||||
networks=$(wpa_cli -i wlan0 list_networks | awk '{print $2}')
|
networks=$(wpa_cli -i $nic_name list_networks | awk '{print $2}' | tail -n +2)
|
||||||
|
|
||||||
# Display network names using dmenu and store the selected network
|
# Display network names using dmenu and store the selected network
|
||||||
selected_network=$(echo "$networks" | dmenu -p "Select a network:")
|
selected_network=$(echo "$networks" | dmenu -p "Select a network:")
|
||||||
|
|
||||||
# Get network ID from network name
|
# Get network ID from network name
|
||||||
network_id=$(wpa_cli -i wlan0 list_networks | grep $selected_network | awk '{print $1}')
|
network_id=$(wpa_cli -i $nic_name list_networks | grep $selected_network | awk '{print $1}')
|
||||||
|
|
||||||
# Check if a network was selected
|
# Check if a network was selected
|
||||||
if [ -n "$network_id" ]; then
|
if [ -n "$network_id" ]; then
|
||||||
# Connect to the selected network using wpa_supplicant
|
# Connect to the selected network using wpa_supplicant
|
||||||
wpa_cli -i wlan0 select_network "$network_id"
|
wpa_cli -i $nic_name select_network "$network_id"
|
||||||
echo "Connecting to $selected_network..."
|
echo "Connecting to $selected_network..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue