You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

barmk.sh 920B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. #
  3. # dtch - (c) wtfpl 2014
  4. # fetch info and print to stdout
  5. clock () {
  6. date '+%H.%M'
  7. }
  8. volume() {
  9. amixer get PCM | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq
  10. }
  11. cpu() {
  12. LINE=`ps -eo pcpu | grep -vE '^\s*(0.0|%CPU)' | sed -n '1h;$!H;$g;s/\n/ +/gp'`
  13. bc <<< $LINE
  14. }
  15. ram() {
  16. read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo | awk '{print $2}'`
  17. bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
  18. }
  19. #nowplaying() {
  20. # cur=`mpc current`
  21. # test "$1" = "scroll" && PARSER='skroll -n20 -d0.5 -r' || PARSER='cat'
  22. # test -n "$cur" && $PARSER <<< $cur || echo "- stopped -"
  23. #}
  24. music() {
  25. echo -n $(test -z "$(mpc current)" || mpc current -f "%title%")
  26. }
  27. while :; do
  28. buf=""
  29. buf="${buf} MPD: $(music) -"
  30. buf="${buf} VOL: $(volume)%% -"
  31. buf="${buf} CLK: $(clock) -"
  32. buf="${buf} RAM: $(ram)%% -"
  33. buf="${buf} CPU: $(cpu)%%"
  34. echo $buf
  35. sleep 1
  36. done