configi3

launching wireguard with a keybining in I3


i'm trying to use some keybinding to start my wireguard vpn, so I've used the following:

bindsym Ctrl+$alt+o exec --no-startup-id wg-quick down wg0 || wg-quick up wg0

but nothing seems to happen, I've also tried to set the suid bit to wg-quick, but still no luck. after reading that ||might cause some issue, i've also tried only the first part

bindsym Ctrl+$alt+o exec --no-startup-id wg-quick down wg0

with and without --no-startup-id but with no luck. Any ideas?


Solution

  • This should be a solution:

    Create and add the line to the file: /etc/sudoers.d/wg-quick

    yourusername yourhostname = (root) NOPASSWD: /usr/bin/wg-quick

    (https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password)

    And then use the full path to wg0.conf in i3/config:

    bindsym $mod+o exec "sudo wg-quick up /etc/wireguard/wg0.conf"