Skip to content

Instantly share code, notes, and snippets.

@tuananh
Last active April 16, 2024 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuananh/a16f76257cce4c83239bc3b7adc3c104 to your computer and use it in GitHub Desktop.
Save tuananh/a16f76257cce4c83239bc3b7adc3c104 to your computer and use it in GitHub Desktop.
i3blocks script to toggle warp on/off

This is a tiny script to toggle Cloudflare Warp on/off.

  • warp-cli status output is changing, unreliable to grep/awk. So I just use https://cloudflare.com/cdn-cgi/trace endpoint.
  • -z "$BLOCK_BUTTON" check is performed in order to see if it's a block click or not.
[cloudflare-warp]
label=
interval=5
command=~/.config/i3/scripts/toggle-warp.sh
#!/usr/bin/env bash
warp_status=$(curl --silent https://cloudflare.com/cdn-cgi/trace | grep "warp=")
if [ -z "$BLOCK_BUTTON" ]; then
echo $warp_status
else
case $warp_status in
warp=on)
warp-cli disconnect;;
warp=off)
warp-cli connect;;
*)
warp-cli disconnect;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment