To be able to connect to wifi, I use nm-applet. When i run nm-applet it puts an icon in the i3 bar where I can select the network to which I want to connect…
But there are no wifi networks… To solve this I use sudo systemctl restart network-manager
.
But I want that every time I start i3, for the icon of wifi networks to be already there.
So in config, I put exec nm-applet
and to show me wifi networks, I try to use sudo systemctl restart network-manager
.
So, the problem is that: I can’t execute commands that need sudo. How can I solve this?
Thanks in advance.
Advertisement
Answer
You could make it so that your user account does not require a password to use sudo
.
Do as root:
EDITOR=vim visudo
Then add to the file:
yourusername ALL=NOPASSWD: ALL
i3 (and any other program, such as your shell), should now be able to execute commands without requiring your password. Please note that there are some security considerations for this, but on most laptops and desktops (things which would use a GUI like i3), it should be fine.
Note: This solution is dangerous and compromises the whole system’s security. Removing password control is even worse than using a standard password
Slightly more secure: You can also make it so that only certain commands can use sudo:
Cmnd_Alias PASSWORDLESS = /usr/bin/systemctl restart network manager yourusername ALL=(ALL) ALL yourusername ALL=(ALL) NOPASSWD: PASSWORDLESS