I3status-rust: Discussion: New block to support nordvpn (status, connecting, disconnecting)

Created on 15 Aug 2019  Â·  5Comments  Â·  Source: greshake/i3status-rust

Hey there,

i3status-rust is amazing, and I would love to contribute to this project. I am pretty new to rust, so I think this feature would not be too hard to implement.

Let me explain, what I would like to do:

I am a nordvpn user. A while ago the company published a nordvpn CLI client for linux. It is kind of basic, but I think it does everything that an ordinary user likes to use.

So, I plan to create a button which shows the status of nordvpn. The on_click event will connect/disconnect to the nordvpn features. An additional parameter can be the country in which the server should stand.

Well, the README advises to first discuss new blocks. So, feel free to comment. I would like to add this feature to the collection of blocks and hope that it will help more people than just me.

Thanks for sharing your thoughts!
Max

discussion

Most helpful comment

I use a toggle block for vpn connection and it is beautiful.

[[block]]
block = "toggle"
text = "VPN"
command_state = "~/.config/i3/vpn.sh status"
command_on = "~/.config/i3/vpn.sh toggle"
command_off = "~/.config/i3/vpn.sh toggle"
interval = 5

And vpn.sh is something like this.

#!/usr/bin/env bash

vpn="kut-dt"

if [[ "${1}" == "status" ]]; then
    if nmcli -t con show $vpn | grep -qi 'VPN connected'; then
        echo ""
    else
        echo ""
    fi

elif [[ "${1}" == "toggle" ]]; then
    if nmcli -t con show $vpn | grep -qi 'VPN connected'; then
        nmcli con down $vpn
        notify-send "VPN Down"
    else
        nmcli con up $vpn
        notify-send "VPN Active"
    fi
fi

All 5 comments

Have you tried using a custom block? It's what I'm using to display the status for a Wireguard connection with another provider.

@ammgws Can you post an example of what your block looks like? It might help the discussion.

I have my custom block running this shell script which uses my VPN provider's API to determine if I'm connected or not and output some pango text to be displayed in the bar. (I'll probably stop using this once the net block gets wg support)

Config is just:

[[block]]
block = "custom"
interval = 60
command = "fish --command=check_vpn --barmode"

Just seems like something that the custom block is suited for. You could add the other functions using the on click options.

I use a toggle block for vpn connection and it is beautiful.

[[block]]
block = "toggle"
text = "VPN"
command_state = "~/.config/i3/vpn.sh status"
command_on = "~/.config/i3/vpn.sh toggle"
command_off = "~/.config/i3/vpn.sh toggle"
interval = 5

And vpn.sh is something like this.

#!/usr/bin/env bash

vpn="kut-dt"

if [[ "${1}" == "status" ]]; then
    if nmcli -t con show $vpn | grep -qi 'VPN connected'; then
        echo ""
    else
        echo ""
    fi

elif [[ "${1}" == "toggle" ]]; then
    if nmcli -t con show $vpn | grep -qi 'VPN connected'; then
        nmcli con down $vpn
        notify-send "VPN Down"
    else
        nmcli con up $vpn
        notify-send "VPN Active"
    fi
fi

@whois-max Please re-open if the alternative methods mentioned above don't work for you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marvin-steinke picture marvin-steinke  Â·  4Comments

YodaEmbedding picture YodaEmbedding  Â·  4Comments

Rikorose picture Rikorose  Â·  5Comments

ammgws picture ammgws  Â·  6Comments

greshake picture greshake  Â·  6Comments