From c8bbfe8b5c0af7a9a6a87830317b0a1d213c7060 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Tue, 23 May 2023 13:42:23 +0200 Subject: [PATCH] Highlight active vpns in the rofi menu --- config/rofi/menus/vpn.fish | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/config/rofi/menus/vpn.fish b/config/rofi/menus/vpn.fish index bcb33790..b432c7b1 100755 --- a/config/rofi/menus/vpn.fish +++ b/config/rofi/menus/vpn.fish @@ -1,8 +1,18 @@ #!/usr/bin/env fish -# User chooses VPN server +# User chooses VPN server, running servers are marked in green set SERVERS (cat ~/NixFlake/config/rofi/menus/servers.txt) # TODO: This file should probably be generated by nix? -set SERVER (echo -e (string join "\n" $SERVERS) | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "vpn" -i) +set PROMPT "" +for SERVER in $SERVERS + set SERVER_RUNNING "$(systemctl list-units wg0-$SERVER.service | grep wg0-$SERVER.service)" + if test -z $SERVER_RUNNING + set PROMPT $PROMPT$SERVER"\n" + else + set PROMPT $PROMPT"$SERVER\n" + end +end +set SERVER (echo -e $PROMPT | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "vpn" -i -markup-rows) +set SERVER (echo -e $SERVER | sd "<.*?>" "") if not contains $SERVER $SERVERS exit end @@ -23,5 +33,5 @@ if test $ACTION = "status" && test -n "$EVAL_RESULT" rofi -theme ~/NixFlake/config/rofi/rofi.rasi -e "$EVAL_RESULT" else if test $ACTION = "start" # Launch chromium in firejail - firejail --noprofile --netns=vpn chromium --incognito ipaddress.my &>/dev/null + firejail --noprofile --private --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null end