Skip to content

A simple Polybar script to display and control WireGuard VPNs.

Notifications You must be signed in to change notification settings

mil-ad/polybar-wireguard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

polybar-wireguard

demo

A simple Polybar script to display and control WireGuard VPNs.

  • Displays the currently connected configuration,
  • Defines --connect, --disconnect, and --toggle switches that can be mapped to different mouse clicks.

Dependencies

  • dmenu so that you can select a WireGuard config from a menu when connecting. This can be replaced by something like rofi or removed altogether by hard-coding a config in the script. You can find my version of dmenu here.
  • networkctl to query currently connected interface without needing sudo. I used to use wg for this but wg needs sudo access and calling it in a loop generated a lot of warnings and logs.
  • Material design icons for the image icon.

Installation

  1. wg-quick binary needs sudo access to run which isn't great news for scripting. I have therefore added a specific rule to my /etc/sudoers (via visudo) to make them password-less:
INSERT_YOUR_USERNAME ALL = (root) NOPASSWD: /usr/bin/wg-quick

⚠️ You obviously don't want to do this for a user who doesn't already have sudo access! WireGuard let's you to add hooks for various events which could let a non-sudo user run arbitrary code.

  1. Edit the configs_path variable in the script to point it to where your WireGuard configs live. If they're in /etc/wireguard you might have to make sure permissions of that directory allows listing the files inside it. I believe by default that directory is only accessible by root.

  2. If you're keeping the default icon from Material font, make sure the font is configured correctly in Polybar and the script. Note that the Polybar font indexing is off by 1. The unmodified script expects the following in the Polybar:

font-3 = Material Icons:style=Regular:size=15
  1. Add a module to Polybar. For example:
[module/wireguard]
type = custom/script
exec = /PATH/TO/wireguard_polybar
tail = false
interval = 1
click-left = /PATH/TO/wireguard_polybar --toggle &

About

A simple Polybar script to display and control WireGuard VPNs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages