This commit is contained in:
2024-06-12 13:49:42 +02:00
commit b8e15ff09c
390 changed files with 37206 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
Copyright 2018 Stephen Gregoratto <dev@sgregoratto.me>
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,46 @@
# nm-vpn
Parses output from `nmcli` to show the current connected VPN name/status
![](images/full.png)
![](images/short.png)
# Requirements
- NetworkManager/`nmcli`
- `sh`
- `awk`
- tested on nawk, gawk, mawk, [goawk](https://github.com/benhoyt/goawk), Plan 9 awk and busybox awk.
# Usage
`nm-vpn` gets active connection info from `nmcli`, looks for interface type `tun`, `tap`, `vpn`. A VPN connection is treated as established only when `tun`|`tap` is present, when it's not and a `vpn` connection is listed as active it is treated as initializing.
# Tunables
`init_color` - color used for marking a connection in initializing state, default is '#FFFF00'
`on_color` - color used for marking a connection in established state, default is '#00FF00'
## Output
When `tun`|`tap` is active, `nm-vpn` will print in the following form:
- Full: `VPN Name`
- Short: `ON`
- Color will be set to `on_color` value
When `tun`|`tap` in not active, `nm-vpn` will print in the following form:
- Full: `VPN Name`
- Short: `INIT`
- Color will be set to `init_color` value
# Config
``` ini
[nm-vpn]
#init_color=#FFFF00
#on_color=#00FF00
label=VPN:
interval=5
```

View File

@@ -0,0 +1,7 @@
[nm-vpn]
#init_color=#FFFF00
#on_color=#00FF00
label=VPN:
interval=5
# vim: syntax=dosini

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

20
.config/i3blocks/nm-vpn/nm-vpn Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env sh
init_color=${init_color:-#FFFF00}
on_color=${on_color:-#00FF00}
export init_color on_color
nmcli -t connection show --active | awk -F ':' '
BEGIN {
init_color=ENVIRON["init_color"]
on_color=ENVIRON["on_color"]
}
$3=="vpn" {
name=$1
status="INIT"
color=init_color
}
$3=="tun" || ($4~/^tap/ || $3~/^tap/) {
if(!name) name=$1
status="ON"
color=on_color
}
END {if(status) printf("%s\n%s\n%s\n", name, status, color)}'