dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

wWifi (681B)


      1 #!/bin/bash 
      2 
      3 awk -F, '{
      4   if ($1 ~ /^nmcli/) {
      5     # custom command + description
      6     print $2
      7   } else {
      8     # regular SSID
      9     print $1
     10   }
     11 }' $HOME/scripts/wifi.csv | wmenu -i | while read selection; do
     12   if [ -z "$selection" ]; then
     13     exit 0
     14   fi
     15 
     16   # search for the selection
     17   awk -F, -v sel="$selection" '
     18   {
     19     if ($1 ~ /^nmcli/ && $2 == sel) {
     20 	  # custom command + description
     21       cmd = $1
     22       found = 1
     23     } else if ($1 == sel) {
     24       cmd = sprintf("nmcli device wifi connect \"%s\" password \"%s\"", $1, $2)
     25       found = 1
     26     }
     27   }
     28   END {
     29     if (found) {
     30       print cmd
     31     }
     32   }' $HOME/scripts/wifi.csv | while read cmd; do
     33     eval "$cmd"
     34   done
     35 done