Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Created December 11, 2013 13:24
Show Gist options
  • Select an option

  • Save ei-grad/7910373 to your computer and use it in GitHub Desktop.

Select an option

Save ei-grad/7910373 to your computer and use it in GitHub Desktop.
P=(`</proc/stat awk 'NR==1 { printf("%d %d %d %d\n", $2, $3, $4, $5) }'`)
while true; do
DT="`date +%c`"
C=(`</proc/stat awk 'NR==1 { printf("%d %d %d %d\n", $2, $3, $4, $5) }'`)
CPU="$(( 100 * ((${C[0]} - ${P[0]}) + (${C[1]} - ${P[1]}) + (${C[2]} - ${P[2]})) / ((${C[0]} - ${P[0]}) + (${C[1]} - ${P[1]}) + (${C[2]} - ${P[2]}) + (${C[3]} - ${P[3]})) ))%"
P=(${C[@]})
xsetroot -name "$CPU $DT"
sleep "0.$((1000000000 - `date '+%N' | sed 's/^0\+//'`))"
done &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment