diff --git a/i3pystatus/openvpn.py b/i3pystatus/openvpn.py index a6f6d98..5230353 100644 --- a/i3pystatus/openvpn.py +++ b/i3pystatus/openvpn.py @@ -30,8 +30,9 @@ class OpenVPN(IntervalModule): status_up = '▲' status_down = '▼' format = "{vpn_name} {status}" - status_command = "bash -c 'systemctl show openvpn@%(vpn_name)s | grep ActiveState=active'" + use_new_service_name = False + status_command = "bash -c 'systemctl show openvpn@%(vpn_name)s | grep ActiveState=active'" vpn_up_command = "sudo /bin/systemctl start openvpn@%(vpn_name)s.service" vpn_down_command = "sudo /bin/systemctl stop openvpn@%(vpn_name)s.service" @@ -46,6 +47,7 @@ class OpenVPN(IntervalModule): ("status_down", "Symbol to display when down"), ("status_up", "Symbol to display when up"), ("vpn_name", "Name of VPN"), + ("use_new_service_name", "Use new openvpn service names (openvpn 2.4^)"), ("vpn_up_command", "Command to bring up the VPN - default requires editing /etc/sudoers"), ("vpn_down_command", "Command to bring up the VPN - default requires editing /etc/sudoers"), ("status_command", "command to find out if the VPN is active"), @@ -55,6 +57,11 @@ class OpenVPN(IntervalModule): if not self.vpn_name: raise Exception("vpn_name is required") + if self.use_new_service_name: + self.status_command = "bash -c 'systemctl show openvpn-client@%(vpn_name)s | grep ActiveState=active'" + self.vpn_up_command = "sudo /bin/systemctl start openvpn-client@%(vpn_name)s.service" + self.vpn_down_command = "sudo /bin/systemctl stop openvpn-client@%(vpn_name)s.service" + def toggle_connection(self): if self.connected: command = self.vpn_down_command