-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Script: vpn-tun-status | ||
|
||
A script that shows the IP address for each active tun adapter. | ||
|
||
![vpn-tun-status](screenshots/1.png) | ||
![vpn-tun-status](screenshots/2.png) | ||
|
||
|
||
## Dependencies | ||
|
||
* `jq` | ||
|
||
|
||
## Module | ||
|
||
```ini | ||
[module/vpn-tun-status] | ||
type = custom/script | ||
exec = ~/polybar-scripts/vpn-tunX-ip.sh | ||
interval = 10 | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
# Set format options | ||
FORMAT_UP='' | ||
FORMAT_DOWN='%{F#FF0000}' | ||
|
||
# Count the number of tun adapters, e.g. tun0, tun1, etc | ||
TUNTAPS=$(ip -j tuntap list | jq -r '.[].ifname' | grep -c '^tun' ) | ||
|
||
if [ "$TUNTAPS" != "0" ]; then | ||
# This filters the JSON output from ip to show "name ip.ip.ip.ip" for each adapter | ||
MESSAGE_UP=$(\ | ||
ip -4 -j addr show \ | ||
| jq '[ .[] | select( .ifname | startswith("tun")) | [ .ifname, .addr_info[0].local ] ]'\ | ||
| jq '[ .[] | join(" ") ]' \ | ||
| jq -r 'join(", ")'\ | ||
) | ||
echo "$FORMAT_UP$MESSAGE_UP" | ||
else | ||
MESSAGE_DOWN='VPN down' | ||
echo "$FORMAT_DOWN$MESSAGE_DOWN" | ||
fi |