From 724366c038777122e292091b729e7d1e9d52c5cc Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 4 Oct 2009 00:21:15 +0200 Subject: Reworked some variables in entropy, load, mpd, net, init --- entropy.lua | 2 +- init.lua | 17 ++++++----------- load.lua | 5 ++--- mpd.lua | 4 ++-- net.lua | 12 ++++++------ 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/entropy.lua b/entropy.lua index 1c1b8e6..ca7ee85 100644 --- a/entropy.lua +++ b/entropy.lua @@ -25,7 +25,7 @@ local function worker(format, poolsize) f:close() -- Calculate percentage - ent_avail_percent = math.ceil(ent_avail * 100 / poolsize) + local ent_avail_percent = math.ceil(ent_avail * 100 / poolsize) return {ent_avail, ent_avail_percent} end diff --git a/init.lua b/init.lua index f2f210a..3e8b654 100644 --- a/init.lua +++ b/init.lua @@ -7,21 +7,16 @@ ----------------------------------------------------- -- {{{ Grab environment -require("awful") -require("vicious.helpers") - -local type = type +local type = type local pairs = pairs -local awful = awful local tonumber = tonumber -local os = { time = os.time } +local helpers = require("vicious.helpers") +local capi = { timer = timer } +local os = { time = os.time } local table = { - insert = table.insert, - remove = table.remove + insert = table.insert, + remove = table.remove } - --- Grab C API -local capi = { timer = timer } -- }}} diff --git a/load.lua b/load.lua index b69e1d3..f2de4b9 100644 --- a/load.lua +++ b/load.lua @@ -20,10 +20,9 @@ local function worker(format) local line = f:read("*line") f:close() - local avg1, avg5, avg15 = - line:match("([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)") + local l1, l5, l15 = line:match("([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)") - return {avg1, avg5, avg15} + return {l1, l5, l15} end -- }}} diff --git a/mpd.lua b/mpd.lua index 3b6df3f..73412eb 100644 --- a/mpd.lua +++ b/mpd.lua @@ -28,10 +28,10 @@ local function worker(format) end -- Sanitize the song name - nowplaying = helpers.escape(np) + local nowplaying = helpers.escape(np) -- Don't abuse the wibox, truncate - nowplaying = helpers.truncate(nowplaying, 30) + local nowplaying = helpers.truncate(nowplaying, 30) return {nowplaying} end diff --git a/net.lua b/net.lua index f38a3dd..7d72708 100644 --- a/net.lua +++ b/net.lua @@ -29,11 +29,11 @@ local function worker(format) for line in f:lines() do -- Match wmaster0 as well as rt0 (multiple leading spaces) if line:match("^[%s]?[%s]?[%s]?[%s]?[%w]+:") then - name = line:match("^[%s]?[%s]?[%s]?[%s]?([%w]+):") + local name = line:match("^[%s]?[%s]?[%s]?[%s]?([%w]+):") -- Received bytes, first value after the name - recv = tonumber(line:match(":[%s]*([%d]+)")) + local recv = tonumber(line:match(":[%s]*([%d]+)")) -- Transmited bytes, 7 fields from end of the line - send = tonumber(line:match("([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$")) + local send = tonumber(line:match("([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$")) args["{"..name.." rx_b}"] = math.floor(recv*10)/10 args["{"..name.." tx_b}"] = math.floor(send*10)/10 @@ -68,11 +68,11 @@ local function worker(format) nets[name].time = os.time() else -- Net stats are absolute, substract our last reading - interval = os.time() - nets[name].time + local interval = os.time() - nets[name].time nets[name].time = os.time() - down = (recv - nets[name][1])/interval - up = (send - nets[name][2])/interval + local down = (recv - nets[name][1])/interval + local up = (send - nets[name][2])/interval args["{"..name.." down_b}"] = math.floor(down*10)/10 args["{"..name.." up_b}"] = math.floor(up*10)/10 -- cgit v1.2.3