My configuration files for Debian/Ubuntu applications
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

40 рядки
879 B

  1. --[[
  2. Licensed under GNU General Public License v2
  3. * (c) 2013, Luca CPZ
  4. * (c) 2010-2012, Peter Hofmann
  5. --]]
  6. local helpers = require("lain.helpers")
  7. local wibox = require("wibox")
  8. local open, match = io.open, string.match
  9. -- System load
  10. -- lain.widget.sysload
  11. local function factory(args)
  12. args = args or {}
  13. local sysload = { widget = args.widget or wibox.widget.textbox() }
  14. local timeout = args.timeout or 2
  15. local settings = args.settings or function() end
  16. function sysload.update()
  17. local f = open("/proc/loadavg")
  18. local ret = f:read("*all")
  19. f:close()
  20. load_1, load_5, load_15 = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
  21. widget = sysload.widget
  22. settings()
  23. end
  24. helpers.newtimer("sysload", timeout, sysload.update)
  25. return sysload
  26. end
  27. return factory