28 lines
		
	
	
		
			630 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			630 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
#source ~/.dotfiles/nfrc.sh
 | 
						|
 | 
						|
cmd="fuzzel --minimal-lines --dmenu --hide-prompt"
 | 
						|
exitnode=$(tailscale status --json | jq .ExitNodeStatus)
 | 
						|
 | 
						|
action=1
 | 
						|
[ "$exitnode" = "null" ] && action=0
 | 
						|
 | 
						|
#action=$(printf "Connect exit node\nDisconnect" | $cmd --index)
 | 
						|
 | 
						|
 | 
						|
case "$action" in
 | 
						|
	0)
 | 
						|
		echo '{"text": "connecting...", "class":"action"}'
 | 
						|
		endpoint=$(tailscale status | grep "exit node" | awk '{print $2}' | $cmd)
 | 
						|
		[ -z "$endpoint" ] && exit
 | 
						|
		tailscale set --exit-node="$endpoint"
 | 
						|
		tailscale up
 | 
						|
		;; 
 | 
						|
	1)
 | 
						|
		echo '{"text": "disconnecting...", "class": "action"}'
 | 
						|
		tailscale set --exit-node=
 | 
						|
		tailscale up
 | 
						|
		;; 
 | 
						|
esac
 |