shervinsahba / polybar-vpn-controller

Polybar module for VPN control. Set up for Mullvad VPN but modifiable for others.
MIT License
62 stars 12 forks source link
mullvad polybar polybar-scripts unixporn vpn-manager

polybar-vpn-controller

Manage your VPN via this module. The vpn_module reports the VPN's status in one of three states: [<location> | Connecting... | No VPN ], where the location is your or public IP address. It also provides the ability to toggle the VPN connection, open a rofi menu with VPN locations to set, and copy your public ip to the clipboard.

The polybar_module_definition file can be appended to your polybar module definitions, adding the vpn module with these preset capabilities:

(Note: This gif is from an older version. The polybar theme seen in the gif was modified from polybar-5 provided by Aditya Shakya and originally designed by Benedikt Vollmerhaus)

changelog

2022-09-24 Reimplemented favorite VPN location arrays.

2022-09-23 Overhauled the package...

supported VPNs

polybar-vpn-controller is scripted to facilitate differing VPN's, but compatibility will depend on your VPN's API. The stock settings are intended for use with Mullvad VPN. See the vpn_module script user settings to judge whether this code can easily be adapted for your choice of VPN. It'd be great to make this module more robust for other VPN's, so please contribute other setups. Thanks!

dependencies

You need a VPN!

optional dependencies

The optional dependencies can be found in the Arch Package Repository.

install

This setup assumes that you use Mullvad, that your polybar configuration is at ~/.config/polybar, and that you are importing module definitions from user_modules.ini. (To setup a VPN other than Mullvad, read the configuration tips in vpn_module. Modify as necessary. Also change the status reporting method in vpn_module to either geoip or some other method. )

cd ~/.config/polybar
git clone https://github.com/shervinsahba/polybar-vpn-controller.git
cd polybar-vpn-controller
./mullvad/update_mullvad_relays
cat polybar_module_definition >> ~/.config/polybar/user_modules.ini

Now add the vpn module to your polybar's config or config.ini.

usage

Run vpn_module help.

  Usage: vpn_module <option>

  options: 
    toggle           toggles VPN connection
    menu             opens rofi menu to select VPN location
    ip-clip          copies ip address to clipboard
    status <method>  reports back with VPN status and location

    methods:
       mullvad       uses mullvad status to print location
       other-vpn     uses a generic method to print location
       geoip         uses the geoip package to print location
       ip            prints ip address

known issues

The Mullvad VPN client may create excessive entries in the system journal because of the way this script calls on it. To suppress these messages in your log, follow these instructions for a distro with systemd. Tested on Manjaro and Arch.