28 lines
966 B
Fish
Executable File
28 lines
966 B
Fish
Executable File
#!/usr/bin/env fish
|
|
|
|
# User chooses VPN server
|
|
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)
|
|
if not contains $SERVER $SERVERS
|
|
exit
|
|
end
|
|
|
|
# User chooses action
|
|
set ACTIONS "start" "stop" "status"
|
|
set ACTION (echo -e (string join "\n" $ACTIONS) | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "action" -i)
|
|
if not contains $ACTION $ACTIONS
|
|
exit
|
|
end
|
|
|
|
# Enable wireguard netdev
|
|
set COMMAND "systemctl $ACTION wg0-$SERVER.service"
|
|
set EVAL_RESULT "$(eval $COMMAND)"
|
|
|
|
if test $ACTION = "status" && test -n "$EVAL_RESULT"
|
|
# Display result if it exists
|
|
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
|
|
end
|