From 7f4629e92812c262bb934561bf998269e6e73887 Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Tue, 3 Jan 2023 16:11:38 +0100 Subject: [PATCH] improved vpn function --- flake.lock | 12 ++++++------ users/rouven/modules/zsh/default.nix | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 41f19e8..3af4077 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672349765, - "narHash": "sha256-Ul3lSGglgHXhgU3YNqsNeTlRH1pqxbR64h+2hM+HtnM=", + "lastModified": 1672688183, + "narHash": "sha256-3sNEWKTg3XXVDnvzVatdyetiUQWL+ibJ1YkvxSk3PuM=", "owner": "nix-community", "repo": "home-manager", - "rev": "dd99675ee81fef051809bc87d67eb07f5ba022e8", + "rev": "c1a830c8fabb13f95f51ecf48552f0a794d8718a", "type": "github" }, "original": { @@ -23,11 +23,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1672441588, - "narHash": "sha256-jx5kxOyeObnVD44HRebKYL3cjWrcKhhcDmEYm0/naDY=", + "lastModified": 1672616430, + "narHash": "sha256-e18rRwDUaW/Uw1tBmtsVueJ2SVI5DLhrEGwhkIo+c50=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6a0d2701705c3cf6f42c15aa92b7885f1f8a477f", + "rev": "0bf3109eeb61780965c27f4a0a4affdcd0cd4d3d", "type": "github" }, "original": { diff --git a/users/rouven/modules/zsh/default.nix b/users/rouven/modules/zsh/default.nix index 56c58ae..63a168f 100644 --- a/users/rouven/modules/zsh/default.nix +++ b/users/rouven/modules/zsh/default.nix @@ -55,7 +55,12 @@ } function svpn() { - systemctl $(echo "start\nstop\nstatus"|fzf) $(systemctl list-unit-files | grep "openconnect\|wg-quick\|wireguard\|openvpn" | cut -d "." -f1 | fzf) + unit=$(systemctl list-unit-files | grep "openconnect\|wg-quick\|wireguard\|openvpn" | cut -d "." -f1 | fzf --preview 'systemctl status {}') + if [ $(systemctl is-active $unit) = "inactive" ]; then + systemctl start $unit + else + systemctl stop $unit + fi } prompt_dir() {