statusbar.sh (1033B)
1 #!/bin/bash 2 # Nicholas Farrow 2019 3 4 crypto_rate () { 5 if [ "$1" == "BTC" ]; then ln=2; else ln=1; fi 6 echo "$(curl -s rate.sx | grep $1 | sed -n ${ln}p | grep -Eo "[0-9]*\.[0-9]*" | head -1)" 7 } 8 9 nordvpn_status () { 10 STATUS=$(nordvpn status) 11 CONNSTAT=$(grep "Status:" <<< "$STATUS" | cut -d ' ' -f2) 12 COUNTRY=$(grep "City:" <<< "$STATUS" | cut -d ' ' -f2) 13 IP=$(grep "IP" <<< "$STATUS" | cut -d ':' -f2) 14 echo "$CONNSTAT $COUNTRY$IP" 15 } 16 17 optimus_status () { 18 echo "$(optimus-manager --print-mode | grep mode | tr " " \\n | tail -1)" 19 } 20 21 22 i3status | while : 23 do 24 # Save output of i3status (generic time date space info) to $line 25 read line 26 27 OPTIMUS=$(optimus_status) 28 29 # Get NordVPN status 30 if command -v nordvpn &> /dev/null; then 31 NORD=$(nordvpn_status) 32 else 33 NORD="" 34 fi 35 36 BTC=$(crypto_rate "BTC") 37 ETH=$(crypto_rate "ETH") 38 RATIO=$(bc <<< "scale=4;$ETH/$BTC") 39 40 echo -e "$OPTIMUS | $NORD | ${RED}BTC: $BTC ETH: $ETH ETH/BTC: 0$RATIO | $line" || exit 1 41 done