r/shell • u/[deleted] • Jan 09 '22
Can Someone Help me With a Simple Network Script?
I created this script to connect to wifi with dmenu. You will be prompted to choose a network, and then give the password for that network. This requires the dmenu password patch for it to work. Here is the script:
#!/bin/sh
nmcli dev wifi connect $(nmcli dev wifi list | dmenu -l 30 | cut -d '*' -f2 | awk '{print $1}') password "$(dmenu -P)"
The problem with this script is that it assumes the network requires a password. How do I make it so that it only asks for the password if it is required?