nix/package/swayscript/script/Vpn.nix

19 lines
339 B
Nix
Raw Normal View History

2024-11-04 04:37:29 +03:00
{ ... }: {
text = ''
# Toggle vpn.
function vpn() {
2024-11-12 14:11:40 +03:00
_notify_short
2024-11-04 04:37:29 +03:00
if [[ "$(_vpn)" = "on" ]]; then
nmcli connection down vpn
else
nmcli connection up vpn
fi
}
2024-07-27 03:35:59 +03:00
2024-11-04 04:37:29 +03:00
function _vpn() {
local state=$(nmcli connection show vpn | rg -i state.*activated)
[ "''${state}" != "" ] && printf on || printf off
}
'';
2024-07-27 03:35:59 +03:00
}