diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-11-11 03:56:43 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-11-11 03:56:43 +0100 |
commit | d0aa48afb8e7ae34f27aa0a29495774f824a6095 (patch) | |
tree | d077b1ed8cda7ab7d0342c8fdc679fe59998437b /entropy.lua | |
parent | 493150c88899572fad92aa04457c90027740aca5 (diff) | |
download | vicious-legacy-d0aa48afb8e7ae34f27aa0a29495774f824a6095.tar.xz |
entropy: widget rewritten, poolsize no longer an argument
Diffstat (limited to 'entropy.lua')
-rw-r--r-- | entropy.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/entropy.lua b/entropy.lua index ce87f84..e2f0e0c 100644 --- a/entropy.lua +++ b/entropy.lua @@ -5,9 +5,9 @@ -- {{{ Grab environment local tonumber = tonumber -local io = { open = io.open } local setmetatable = setmetatable local math = { ceil = math.ceil } +local helpers = require("vicious.helpers") -- }}} @@ -16,15 +16,16 @@ module("vicious.entropy") -- {{{ Entropy widget type -local function worker(format, poolsize) - -- Linux 2.6 has a default entropy pool of 4096-bits - if poolsize == nil then poolsize = 4096 end +local function worker(format) + local random = setmetatable( + { _path = "/proc/sys/kernel/random"}, + helpers.pathtotable + ) + -- Linux 2.6 has a default entropy pool of 4096-bits + local poolsize = tonumber(random.poolsize) -- Get available entropy - local f = io.open("/proc/sys/kernel/random/entropy_avail") - local ent = tonumber(f:read("*line")) - f:close() - + local ent = tonumber(random.entropy_avail) -- Calculate percentage local ent_percent = math.ceil(ent * 100 / poolsize) |