Update .config/polybar/scripts/wifi-menu.sh

This commit is contained in:
punkfairie 2024-07-28 18:07:59 -07:00
parent 17464d3b42
commit d37e12e84b
Signed by: punkfairie
GPG key ID: A86AF57F837E320F

View file

@ -12,9 +12,9 @@ elif [[ "$connected" =~ "disabled" ]]; then
fi
# Use rofi to select wifi network
chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " -theme ~/.config/polybar/mytheme/scripts/rofi/powermenu.rasi)
chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " -theme ~/.config/polybar/scripts/rofi/powermenu.rasi)
# Get name of connection
read -r chosen_id <<< "${chosen_network:3}"
read -r chosen_id <<<"${chosen_network:3}"
if [ "$chosen_network" = "" ]; then
exit
@ -24,16 +24,15 @@ elif [ "$chosen_network" = "󰖪 Disable Wi-Fi" ]; then
nmcli radio wifi off
else
# Message to show when connection is activated successfully
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
# Get saved connections
saved_connections=$(nmcli -g NAME connection)
if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
nmcli connection up id "$chosen_id" | grep "successfully" && notify-send "Connection Established" "$success_message"
else
if [[ "$chosen_network" =~ "" ]]; then
wifi_password=$(rofi -dmenu -p "Password: " -theme ~/.config/polybar/colorblocks/scripts/rofi/launcher.rasi)
wifi_password=$(rofi -dmenu -p "Password: " -theme ~/.config/polybar/scripts/rofi/launcher.rasi)
fi
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message"
fi
fi
fi