Last active
July 7, 2022 09:05
-
-
Save Traumatism/5cab782b55afd1255bc71f4ef42fdc78 to your computer and use it in GitHub Desktop.
Fetch Mullvad informations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
r="[31m" # red | |
y="[33m" # yellow | |
w="[37m" # 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