1

Generate file with available vpn tunnels for rofi

This commit is contained in:
2023-05-25 00:06:09 +02:00
parent 6779888b15
commit f5c25b7a0b
5 changed files with 12 additions and 6 deletions

View File

@ -1,2 +0,0 @@
de-115
lu-16

View File

@ -1,10 +1,10 @@
#!/usr/bin/env fish #!/usr/bin/env fish
# User chooses VPN server, running servers are marked in green # 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 SERVERS (cat /etc/rofi-vpns) # TODO: This file should probably be generated by nix?
set PROMPT "" set PROMPT ""
for SERVER in $SERVERS for SERVER in $SERVERS
set SERVER_RUNNING "$(systemctl list-units wg0-$SERVER.service | grep wg0-$SERVER.service)" set SERVER_RUNNING "$(systemctl list-units $SERVER.service | grep $SERVER.service)"
if test -z $SERVER_RUNNING if test -z $SERVER_RUNNING
set PROMPT $PROMPT$SERVER"\n" set PROMPT $PROMPT$SERVER"\n"
else else
@ -25,7 +25,7 @@ if not contains $ACTION $ACTIONS
end end
# Enable wireguard netdev # Enable wireguard netdev
set COMMAND "systemctl $ACTION wg0-$SERVER.service" set COMMAND "systemctl $ACTION $SERVER.service"
set EVAL_RESULT "$(eval $COMMAND)" set EVAL_RESULT "$(eval $COMMAND)"
if test $ACTION = "status" && test -n "$EVAL_RESULT" if test $ACTION = "status" && test -n "$EVAL_RESULT"
@ -36,5 +36,5 @@ else if test $ACTION = "start"
# NOTE: With a shared home directory, firejail uses the same instance, so it won't work to # NOTE: With a shared home directory, firejail uses the same instance, so it won't work to
# launch multiple browsers with different VPNs... # launch multiple browsers with different VPNs...
# firejail --noprofile --allusers --private="~/.firejail-home" --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null # firejail --noprofile --allusers --private="~/.firejail-home" --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null
firejail --noprofile --private --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null firejail --noprofile --private --netns="$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null
end end

View File

@ -60,6 +60,7 @@
"nextcloud" "nextcloud"
"nnn" "nnn"
"ranger" "ranger"
"rofi"
"vscode" "vscode"
"waybar" "waybar"
]; ];

View File

@ -1,3 +1,4 @@
# TODO: Generate file with names for rofi
{ {
config, config,
nixosConfig, nixosConfig,

View File

@ -1,3 +1,4 @@
# TODO: Generate file with VPN names for rofi
# TODO: Need to set permissions through polkit module # TODO: Need to set permissions through polkit module
# TODO: Setup Wireless (IWD/Networkd?) # TODO: Setup Wireless (IWD/Networkd?)
{ {
@ -27,6 +28,11 @@ in {
# Wireguard VPNs # Wireguard VPNs
systemd.services = cfg.wireguard-tunnels; systemd.services = cfg.wireguard-tunnels;
environment.etc."rofi-vpns".text = let
names-list = attrNames cfg.wireguard-tunnels;
names = concatStringsSep "\n" names-list;
in
names;
# General Networking Settings # General Networking Settings
networking = { networking = {