Guest User

Untitled

a guest
Feb 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'rubygems'
  3. require 'awesomer'
  4.  
  5. def meminfo(key)
  6. `cat /proc/meminfo | grep #{key}`[/\d+/].to_i / 1024
  7. end
  8.  
  9. def load
  10. `uptime`[/e: (\d\.\d\d),/, 1]
  11. end
  12.  
  13. def volume(mixer)
  14. `amixer get #{mixer}`.scan(/\[(\d+)%\]/)
  15. end
  16.  
  17. def battery
  18. `acpi`[/\d{1,3}%/]
  19. end
  20.  
  21. Awesomer.contact do |a|
  22. MEM_TOTAL = meminfo :MemTotal
  23.  
  24. a.statusbar = :status
  25.  
  26. loop do
  27. a.widget_tell :battery, :text, "[#{battery}]"
  28. a.widget_tell :memory, :text,
  29. "[#{MEM_TOTAL-meminfo(:MemFree)}/#{MEM_TOTAL}MB"
  30. a.widget_tell :load, :text, "#{load}]"
  31. a.widget_tell :volume, :text, "[#{volume(:PCM).join('/')}%]"
  32. a.widget_tell :clock, :text, Time.now.strftime('[%Y-%m-%d %H:%M]')
  33. sleep 1
  34. end
  35. end
Add Comment
Please, Sign In to add comment