small pixel drawing of a pufferfish dotfiles

Add simple vpn suite
Jes Olson jolson@digitalocean.com
Wed, 05 Jan 2022 14:42:03 -0600
commit

65fe714d83569633a150cea05f0b416ef76141cd

parent

46fa6d6f57eb55b4278663c288cf75eed7428785

3 files changed, 39 insertions(+), 7 deletions(-)

jump to
M .config/sway/zora.config/sway/zora

@@ -1,4 +1,4 @@

-output * bg /home/j3s/Pictures/whale.jpg fill +output * bg /home/j3s/Pictures/flowers.jpg tile # This will lock your screen after 300 seconds of inactivity, then turn off # your displays after another 300 seconds, and turn your screens back on when

@@ -13,6 +13,9 @@ for_window [class="Firefox"] inhibit_idle fullscreen

for_window [class="Chromium"] inhibit_idle fullscreen bindsym $mod+Shift+i exec jira-fuzzel +bindsym $mod+Prior exec vpn +bindsym $mod+Next exec vpn kill # Laptop outputs are managed automatically using kanshi -exec_always pkill kanshi; exec kanshi +# see https://github.com/emersion/kanshi/issues/43 +exec_always pkill kanshi; exec kanshi &> /tmp/kanshi.debug
M bin/zora/statusbarbin/zora/statusbar

@@ -2,12 +2,21 @@ #!/bin/sh

while true do - battery="🐟 $(cat /sys/class/power_supply/BAT0/capacity)%" - wifi="🐡 $(nmcli ge status | grep -v STATE | awk '{print $1}')" + vpn="disconnected" + if ip link ls tun0 > /dev/null 2>&1; then + vpn="connected" + fi + wifi="disconnected (0%)" + if nmcli dev show wlp0s20f3 | grep GENERAL.STATE | grep -q connected; then + wifiname="$(nmcli dev show wlp0s20f3 | awk '/GENERAL.CONNECTION/ {print $2}')" + wifistrength="$(nmcli dev show wlp0s20f3 | awk '/GENERAL.STATE/ {print $2}')" + wifi="$wifiname ($wifistrength%)" + fi + battery="$(cat /sys/class/power_supply/BAT0/capacity)%" time=$(date +"%A %Y-%m-%d %I:%M %p") - est_time=$(TZ=America/New_York date +"(%I:%M ET)") - time="🦈 $time $est_time $(date -u +"(%H:%M UTC)")" + est_time=$(TZ=America/New_York date +"(🗽%I:%M ET)") + time="$time $est_time $(date -u +"(🤖%H:%M UTC)")" # --date='TZ="America/New_York" - printf "%s | %s | %s\n" "${wifi}" "${battery}" "${time}" + printf "%s | %s | %s\n" "💓 ${wifi} (vpn $vpn)" "🥤 ${battery}" "${time}" sleep 10 done
A bin/zora/vpn

@@ -0,0 +1,20 @@

+#!/bin/sh +# +# connects or kills the gp +# vpn tunnel + +if [ "$1" = "kill" ]; then + notify-send '🤬 killing vpn' -t 2000 + sudo pkill openconnect +else + notify-send '👼 connecting vpn' -t 1000 + # the two-line pipe method used here was described + # in this issue: https://github.com/dlenski/openconnect/issues/103#issuecomment-383416545 + if pgrep openconnect; then + sleep 1 + notify-send '😳 vpn already running' -t 2000 + exit + fi + printf "%s\n%s" "$(pa show vpn)" "1" | + sudo openconnect -u jolson --passwd-on-stdin --protocol=gp https://vpn-nyc3.digitalocean.com/ssl-vpn +fi