Advertisement
Guest User

barstatus

a guest
Aug 30th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # z3bra - (c) wtfpl 2014
  4. # Fetch infos on your computer, and print them to stdout every second.
  5.  
  6. clockico='\ue017'
  7.  
  8. clock() {
  9.     date '+%H:%M'
  10. }
  11.  
  12. battery() {
  13.     acpi | cut -d ',' -f 2
  14. }
  15.  
  16. volume() {
  17.     amixer get Master | sed -n 'N;s/^.*\[\([0-9]\+%\).*$/\1/p'
  18. }
  19.  
  20. cpuload() {
  21.     LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
  22.     bc <<< $LINE
  23. }
  24.  
  25. memused() {
  26.     read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
  27.     bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
  28. }
  29.  
  30. network() {
  31.     read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
  32.     if iwconfig $int1 >/dev/null 2>&1; then
  33.         wifi=$int1
  34.         eth0=$int2
  35.     else
  36.         wifi=$int2
  37.         eth0=$int1
  38.     fi
  39.     ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 ||int=$wifi
  40.  
  41.     #int=eth0
  42.  
  43.     ping -c 1 8.8.8.8 >/dev/null 2>&1 &&
  44.         echo "$int connected" || echo "$int disconnected"
  45. }
  46.  
  47. groups() {
  48.     xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'
  49. }
  50.  
  51. mail() {
  52.     ls -rA1 /home/tingol/mail/INBOX/new | wc -l
  53. }
  54.  
  55. # This loop will fill a buffer with our infos, and output it to stdout.
  56. while :; do
  57.     buf="%{l} %{B#FF1c2027} "
  58. #    buf="${buf} [$(groups)]   --  "
  59.     buf="${buf} %{F#FF8e44ad}$(cmusstatus) %{c} "
  60.     buf="${buf} %{F#FF72d5a3} $(clock) %{r} "
  61.     buf="${buf} %{F#FF3498db}$(dbstatus)"
  62.     buf="${buf} %{F#FF3aaf75} $(cpuload) "
  63.     buf="${buf} %{F#FFffaa3e} $(mail) "
  64.     buf="${buf} %{F#FFe74c3c} $(battery)%"
  65.  
  66.     echo $buf
  67.     # use `nowplaying scroll` to get a scrolling output!
  68.     sleep 10 # The HUD will be updated every second
  69. done
  70.  
  71. cmusstatus() {
  72.     cmus-remote -Q | awk '$2 == "artist"{a=substr($0,12)} $2 == "title"{t=substr($0,11); exit} END{printf("%s - %s\n",a,t); exit(!t)}'
  73. }
  74.  
  75. dbstatus(){
  76.  
  77.     dropbox status
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement