This file contains 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
#!/usr/bin/env bash | |
#script is based on: https://raw.githubusercontent.com/matryer/bitbar-plugins/master/Network/bandwidth.1s.sh | |
#Do this first: | |
#sudo apt install ifstat sysstat lm-sensors | |
#sudo sensors-detect | |
netspeed=$(ifstat -n -w -i wlp1s0 0.1 1 | tail -n 1 | awk '{print "▼", $1, "▲", $2;}') | |
mem=$(free | grep Mem | awk '{print $3/$2 * 100.0}') | |
CPU=$(mpstat 1 1 | awk '$3 ~ /CPU/ { for(i=1;i<=NF;i++) { if ($i ~ /%idle/) field=i } } $3 ~ /all/ { printf("%d",100 - $field) }') | |
temp=$(sensors | grep -oP 'CPU.*?\+\K[0-9.]+') | |
battery=$(upower -i $(upower -e | grep BAT) | grep --color=never -E percentage|xargs|cut -d' ' -f2|sed s/%//) | |
batstatus=$(upower -i $(upower -e | grep BAT) | grep --color=never -E state|xargs|cut -d' ' -f2|sed s/%//) | |
freq=$(lscpu | grep 'CPU MHz' | awk '{printf "%0.1f", $3/1000}') | |
if [ $batstatus = "charging" ]; then | |
batstatussymbol="⚡" | |
elif [ $batstatus = "discharging" ]; then | |
batstatussymbol="" | |
elif [ $batstatus = "fully-charged" ]; then | |
batstatussymbol="Full" | |
fi | |
echo "($netspeed) (C-${CPU%%.*}% M-${mem%%.*}% T-${temp%%.*}°C) ($freq GHz) (B-${battery%%.*}% $batstatussymbol)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment