Skip to content

Instantly share code, notes, and snippets.

@extratone
Forked from idnovic/shellfishwidget.sh
Created October 13, 2022 06:18
Show Gist options
  • Save extratone/ed71d9aae5c14350901b812b8448886a to your computer and use it in GitHub Desktop.
Save extratone/ed71d9aae5c14350901b812b8448886a to your computer and use it in GitHub Desktop.
shellfish widget
#!/bin/bash
source .bashrc
loadavg=$(cat /proc/loadavg | awk '{print $2}' | sed 's/[^0-9]*//g')
cpucount=$(sed -n '/ cores/ s/[^0-9]//gp' /proc/cpuinfo | sed '1,1d')
cpu=$(($loadavg/$cpucount))
memtotal=$(sed -n '/^MemTotal:/ s/[^0-9]//gp' /proc/meminfo)
memavail=$(sed -n '/^MemAvailable:/ s/[^0-9]//gp' /proc/meminfo)
mem=$(((($memtotal-$memavail))/($memtotal/100)))
io=$(iostat -d --dec=0 -hmsxz -p ALL -g hdd ALL -H | grep hdd | awk '{print $7}')
hdd=$(df / | grep dev | awk '{print $5}')
#netavg=$(nicstat -nMz | grep -m1 -A1 %Util | sed '1,1d' | awk '{print $9}' | sed 's/[^1-9]*//g')
#net=$(awk "BEGIN {printf \"%.0f\",${netavg}}")
widget cpu "$cpu%" memorychip "$mem%" externaldrive.badge.timemachine "$io"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment