nix/package/swayscript/script/Vpn.nix

19 lines
338 B
Nix
Raw Normal View History

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