Skip to content

Instantly share code, notes, and snippets.

@Traumatism
Last active July 7, 2022 09:05
Show Gist options
  • Save Traumatism/5cab782b55afd1255bc71f4ef42fdc78 to your computer and use it in GitHub Desktop.
Save Traumatism/5cab782b55afd1255bc71f4ef42fdc78 to your computer and use it in GitHub Desktop.
Fetch Mullvad informations
#!/bin/sh
r="" # red
y="" # yellow
w="" # white
STATE_ICON=""
IP_ICON="ﰍ"
SERVER_ICON=""
ACCOUNT_ICON=""
FIRST_DIGITS="$(mullvad account get | grep -Eo "\d{16}" | cut -c1-4) #### #### ####"
DATA=$(curl https://ipv4.am.i.mullvad.net/json -s)
if [ $(echo $DATA | jq .mullvad_exit_ip) = 'true' ]; then
IP=$(echo $DATA | jq .ip | tr -d "\"")
SERVER=$(echo $DATA | jq .mullvad_exit_ip_hostname | tr -d "\"")
STATE="connected"
else
IP="hidden";
SERVER="n/a";
STATE="disconnected"
fi;
TITLE="$USER@mullvad"
STATE_LINE="$r$STATE_ICON$w $STATE$w"
SERVER_LINE="$r$SERVER_ICON$w $SERVER$w"
IP_LINE="$r$IP_ICON$w $IP$w"
ACCOUNT_LINE="$r$ACCOUNT_ICON$w $FIRST_DIGITS$w"
echo "$y ______ $w "
echo "$y / \ $w $TITLE"
echo "$y / __\\$w __$y o$w $(for ((i=0; i<${#TITLE}; i++)); do printf "-"; done)"
echo "$y | _/ $w / $STATE_LINE"
echo "$y \._/ $w / $IP_LINE"
echo " / ____/ $SERVER_LINE"
echo " / \ $ACCOUNT_LINE"
echo " '._____.' "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment