Created
October 8, 2020 17:36
-
-
Save un-def/656b91b27a4b881358275a69923b77e7 to your computer and use it in GitHub Desktop.
Persistent i3blocks blocket displaying VPN connection status
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
#!/bin/sh | |
ON='{"full_text": "", "color": "#00ff00"}' | |
OFF='{"full_text": "", "color": "#ff0000"}' | |
dbus-send --system \ | |
--print-reply \ | |
--dest=org.freedesktop.NetworkManager \ | |
/org/freedesktop/NetworkManager \ | |
org.freedesktop.DBus.Properties.Get \ | |
string:org.freedesktop.NetworkManager string:PrimaryConnectionType \ | |
| sed -n '1d;s/.*string "vpn"/'"${ON}"'/p;t;s/.*/'"${OFF}"'/p' | |
dbus-monitor --system "\ | |
type='signal', \ | |
sender='org.freedesktop.NetworkManager', \ | |
interface='org.freedesktop.DBus.Properties', \ | |
member='PropertiesChanged', \ | |
arg0='org.freedesktop.NetworkManager'" \ | |
2> /dev/null \ | |
| stdbuf -oL sed -n '/"PrimaryConnectionType"/{n;s/.*string "vpn"/'"${ON}"'/p;t;s/.*/'"${OFF}"'/p}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i3blocks config