Prevent/Supress showing popup of Wifi Connection asking for password on terminal command

Im working on a C++ program that can execute terminal commands for me, and one of its functions is wifi manipulation (connect, disconnect, forget). Right now I am trying to execute a wifi connection command in the terminal using the ff.:

nmcli device wifi connect <wifiName> password <password>

Above works fine in the terminal when the password is right, but it shows a popup asking for the correct password when the supplied password is wrong:

Wifi Connection popup after executing terminal command

Is there a way I can prevent the popup from happening, so my program doesn't pause indefinitely until I close it manually? Or is there a better command to handle wifi connection given the wifi name and password?

5

1 Answer

from man nmcli

you can use below command.

but you may require few more details other than just ssid and password

nmcli connection add type wifi ifname wlp2s0 ssid H con-name PRATAP2 +802-11-wireless-security.key-mgmt WPA-PSK +802-11-wireless-security.psk 50251919

the details here I used other than ssid and password are

ifname
+802-11-wireless-security.key-mgmt

the nmcli command above will not popup as in your Question, It will popup a msg like in this gif file below which will not stop your work flow if the password is wrong...

My required details are:

ifname is wlp2s0
SSID is `H`
password is 50251919
wireless security key is WPA-PSK

So the command to add this connection with the password is as above..

Observe the below gif at the end.. when I entered wrong password.. It did not disturb the running process.. Instead It Just Showed a Notification at the top, If we want to enter the password again, we can click it other wise Ignore..

Note: This method works if there are no connections exist.

enter image description here

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like