Sunday, April 26, 2020

configuring i3 with py3status

i used to run the vpn connection from the terminal. I could not find a way to make the i3 status show the correct status when the VPN was running. i use the py3status and taking a look in the documentation i though that it would be as simple as to edit the i3 configuration to point to a pid file that i would store the pid process when i run the openvpn. Something like

vpn_status {
  check_pid = True                 
  pidfile = "/var/run/openvpn-client/myvpn.pid"
}
and adding in the vpn config

writepid /var/run/openvpn-client/myvpn.pid

After some research and taking a look in the vpn_status module of the py3status, i decided to try my luck using the NetworkManager. This work quite well as the module checks for dbus messages of the NetworkManager. the modue does not need any additional in the py3status config.

To add the vpn connection from nmcli, the commands are:

sudo nmcli connection import type openvpn file /etc/openvpn/myvpn.ovpn 

Add the username to the vpn connection that it needs to connect

nmcli connection modify myvpn +vpn.data username=<username>

And finally run the onnection up using --ask to prompt for the password of that specific user

sudo nmcli --ask connection up myvpn
Now the i3 status shows the VPN is up and running displaying the name of the vpn. Giving the correct password you should see that the connection is activation (Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)

With ip route you can check that vpn has setup the routing. in my case i have a problem as it adds a default route to the vpn address which could not see outside. i had to delete this because i could not access the Internet

sudo ip r delete default via 10.100.200.1

if you want to close the connection

nmcli connection down myvpn

i dont know how i could do that without NetworkManager but i would be happy if someone has some hints.