Add rofi vpn menu
This commit is contained in:
@ -176,6 +176,7 @@ bind = $mainMod, D, exec, ~/NixFlake/config/rofi/menus/systemd-podman.fish
|
||||
bind = $mainMod, escape, exec, ~/NixFlake/config/rofi/menus/power.fish
|
||||
bind = $mainMod, O, exec, ~/NixFlake/config/rofi/menus/lectures.fish
|
||||
bind = $mainMod, M, exec, ~/NixFlake/config/rofi/menus/keybinds.fish
|
||||
bind = $mainMod, U, exec, ~/NixFlake/config/rofi/menus/vpn.fish
|
||||
|
||||
# Launch apps
|
||||
bind = $mainMod, T, exec, kitty
|
||||
|
1
config/rofi/menus/servers.txt
Normal file
1
config/rofi/menus/servers.txt
Normal file
@ -0,0 +1 @@
|
||||
DE-115
|
@ -15,11 +15,10 @@ if not contains $ACTION $ACTIONS
|
||||
end
|
||||
|
||||
# Execute command
|
||||
set COMMAND_ROOT "pkexec --user root systemctl $ACTION podman-$SERVICE.service"
|
||||
set COMMAND_USER "systemctl $ACTION podman-$SERVICE.service"
|
||||
set EVAL_RESULT "$(eval $COMMAND_USER)"
|
||||
set COMMAND "systemctl $ACTION podman-$SERVICE.service"
|
||||
set EVAL_RESULT "$(eval $COMMAND)"
|
||||
|
||||
# Display result if it exists
|
||||
if test -n "$EVAL_RESULT"
|
||||
if test $ACTION = "status" && test -n "$EVAL_RESULT"
|
||||
# Display result if it exists
|
||||
rofi -theme ~/NixFlake/config/rofi/rofi.rasi -e "$EVAL_RESULT"
|
||||
end
|
||||
|
27
config/rofi/menus/vpn.fish
Executable file
27
config/rofi/menus/vpn.fish
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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
|
Reference in New Issue
Block a user