#!/bin/sh

choice=$(echo -e "up\ndown\nconnect" | dmenu -p "Do you wish to connect to a wi-fi or disconnect?:")

case $choice in
    "up"|"down")
        ssid=$(nmcli -t -f ssid dev wifi| cut -d\' -f2 | dmenu -p "Select Wifi  " -l 20)
        nmcli c $choice "$ssid" ;;
    "connect")
        bssid=$(nmcli device wifi list | sed -n '1!p' | cut -b 9- | dmenu -p "Select Wi-Fi  :" -l 20 | cut -d' ' -f1)
        pass=$(echo "" | dmenu -P -p "Enter Password  : ") 
        nmcli device wifi connect $bssid password $pass ;;
esac