Skip to content

Commit

Permalink
Use available in-memory or on-disk connection profiles
Browse files Browse the repository at this point in the history
Fixes sineto#13
  • Loading branch information
jonnieey committed Sep 20, 2020
1 parent 0ce9308 commit 898e728
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions nmcli-rofi
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ function cleanup_networks () {
| while read line; do nmcli con delete uuid $line; done
}

function get_available_connections() {
avail_conn=$(nmcli connection show | cut -d" " -f1 | tail -n +2)
echo $avail_conn
}

function main () {
if [ -r "$DIR/config" ]; then
source "$DIR/config"
Expand All @@ -141,6 +146,7 @@ function main () {
OPS=$(rofi_menu)
CHSSID=$(get_ssid_device "$OPS", 1)
CHDEV=$(get_ssid_device "$OPS", 3)
AVALABLE_CONNECTIONS=$(get_available_connections)

if [[ "$OPS" =~ 'Disable' ]]; then
nmcli radio wifi off
Expand Down Expand Up @@ -169,8 +175,16 @@ function main () {

else
if [[ "$OPS" =~ "WPA2" ]] || [[ "$OPS" =~ "WEP" ]]; then
WIFIPASS=$(echo -en "" | rofi -dmenu -password -p "PASSWORD" \
-mesg "Enter the PASSWORD of the network" -lines 0 -font "$FONT")
if [[ `echo "$AVALABLE_CONNECTIONS" |grep -w "$CHSSID"` ]]; then
nmcli c u "$CHSSID"
else
WIFIPASS=$(echo -en "" | rofi -dmenu -password -p "PASSWORD: " \
-mesg "Enter the PASSWORD of the network" -lines 0 -font "$FONT")

if [[ "$CHSSID" != '' ]] && [[ "$WIFIPASS" != '' ]]; then
nmcli dev wifi con "$CHSSID" password "$WIFIPASS" ifname "$CHDEV"
fi
fi
fi

if [[ "$CHSSID" != '' ]] && [[ "$WIFIPASS" != '' ]]; then
Expand Down

0 comments on commit 898e728

Please sign in to comment.