Skip to content

Instantly share code, notes, and snippets.

@ubuntuvibes ubuntuvibes/sysinfo.1s.sh
Last active Mar 25, 2017

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.