Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Dec 8th, 2012  |  syntax: None  |  size: 2.23 KB  |  hits: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # Variables
  4. refresh=1
  5. statbar="sysbar"
  6. terminal="xterm -e"
  7. browser="chromium"
  8. alignment="right"
  9. color0="#666666"
  10. color1="#C2FFA0"
  11. separator="^s[${alignment};${color0};  ]"
  12. net_interface="eth0"
  13. guser="CHANGE ME"
  14. gpass="CHANGE ME"
  15.  
  16. _time() {
  17.     time="$(date +%X)"
  18.     echo "^s[${alignment};${color0};\[TIME\]] ^s[${alignment};${color1}; ${time}]"
  19. }
  20.  
  21. _date() {
  22.     date="$(date +%d-%m-%Y)"
  23.     echo "^s[${alignment};${color0};\[DATE\]] ^s[${alignment};${color1}; ${date}]"
  24. }
  25.  
  26. _cpu() {
  27.     cpu="$(eval $(awk '/^cpu /{print "previdle=" $5 "; prevtotal=" $2+$3+$4+$5 }' /proc/stat); sleep 0.4;
  28.               eval $(awk '/^cpu /{print "idle=" $5 "; total=" $2+$3+$4+$5 }' /proc/stat);
  29.               intervaltotal=$((total-${prevtotal:-0}));
  30.               echo "$((100*( (intervaltotal) - ($idle-${previdle:-0}) ) / (intervaltotal) ))")"
  31.     echo "^s[${alignment};${color0};\[CPU\]](1;spawn;${terminal} htop) ^s[${alignment};${color1}; ${cpu}%]"
  32. }
  33.  
  34. _memory() {
  35.     mem_used="$(free -m | sed -n 's|^-.*:[ \t]*\([0-9]*\) .*|\1|gp')"
  36.     mem_total="$(free -m | sed -n 's|^M.*:[ \t]*\([0-9]*\) .*|\1|gp')"
  37.     echo "^s[${alignment};${color0};\[RAM\]](1;spawn;${terminal} htop) ^s[${alignment};${color1}; ${mem_used}\/${mem_total} MB]"
  38. }
  39.  
  40. _netstats() {
  41.     net_upload_total="$(cat /sys/class/net/${net_interface}/statistics/tx_bytes)"
  42.     net_download_total="$(cat /sys/class/net/${net_interface}/statistics/rx_bytes)"
  43.     net_upload=$((($net_upload_total)/1000000))
  44.     net_download=$((($net_download_total)/1000000))
  45.     echo "^s[${alignment};${color0};\[NET\]] ^s[${alignment};${color1}; ${net_upload}\/${net_download} Kbp/s]"
  46. }
  47.  
  48. _mail() {
  49.     mail=$(curl -u ${guser}:${gpass} --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" | wc -l)
  50.     echo "^s[${alignment};${color0};\[MAIL\]](1;spawn;${browser} https://mail.google.com) ^s[${alignment};${color1}; ${mail}]"
  51. }
  52.  
  53. while [ -n "$(ps U ${UID} | awk '{print $5}' | grep ^wmfs$)" ]; do
  54.         wmfs -c status "${statbar} $(_time) ${separator} $(_date) ${separator} $(_cpu) ${separator} $(_memory) ${separator} $(_netstats)" # ${separator} $(_mail)
  55.         sleep $refresh
  56. done