]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

revert to previous stable
authorLuke Bonham <dada@archlinux.info>
Tue, 20 Oct 2015 13:17:44 +0000 (15:17 +0200)
committerLuke Bonham <dada@archlinux.info>
Tue, 20 Oct 2015 13:17:44 +0000 (15:17 +0200)
15 files changed:
helpers.lua
widgets/abase.lua
widgets/alsa.lua
widgets/alsabar.lua
widgets/base.lua
widgets/bat.lua
widgets/cpu.lua
widgets/fs.lua
widgets/imap.lua
widgets/maildir.lua
widgets/mem.lua
widgets/mpd.lua
widgets/net.lua
widgets/sysload.lua
widgets/temp.lua

index 503c40eaf0dbc54df0854e2f86f08e90d4799670..4e90e169c15a570bb31aa4c6fa3f1ac9e70c5336 100644 (file)
@@ -76,16 +76,10 @@ end
 
 helpers.timer_table = {}
 
-function helpers.newtimer(_name, timeout, fun, nostart)
-    local name = timeout
-
-    if not helpers.timer_table[name] then
-        helpers.timer_table[name] = capi.timer({ timeout = timeout })
-        helpers.timer_table[name]:start()
-    end
-
+function helpers.newtimer(name, timeout, fun, nostart)
+    helpers.timer_table[name] = capi.timer({ timeout = timeout })
     helpers.timer_table[name]:connect_signal("timeout", fun)
-
+    helpers.timer_table[name]:start()
     if not nostart then
         helpers.timer_table[name]:emit_signal("timeout")
     end
index 87af8725222f08f3241280021de928d6d17d3971..98f7818d844fe2b2c7c004b2ed39a9abacd91eb9 100644 (file)
@@ -6,9 +6,9 @@
                                                   
 --]]
 
-local helpers = require("lain.helpers")
-local async   = require("lain.asyncshell")
-local wibox   = require("wibox")
+local newtimer     = require("lain.helpers").newtimer
+local async        = require("lain.asyncshell")
+local wibox        = require("wibox")
 
 local setmetatable = setmetatable
 
@@ -19,26 +19,21 @@ local setmetatable = setmetatable
 local function worker(args)
     local abase    = {}
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 5
     local cmd      = args.cmd or ""
     local settings = args.settings or function() end
 
     abase.widget = wibox.widget.textbox('')
-    helpers.set_map(cmd, '')
 
     function abase.update()
         async.request(cmd, function(f)
             output = f
-
-            if helpers.get_map(cmd) ~= output then
-                widget = abase.widget
-                settings()
-                helpers.set_map(cmd, output)
-            end
+            widget = abase.widget
+            settings()
         end)
     end
 
-    helpers.newtimer(cmd, timeout, abase.update)
+    newtimer(cmd, timeout, abase.update)
 
     return setmetatable(abase, { __index = abase.widget })
 end
index 0bb205996054e12ff539e74624af637c3540ffdd..85d53114e132a683fe2af8af9f86908af61b8f39 100644 (file)
@@ -19,14 +19,11 @@ local setmetatable    = setmetatable
 
 -- ALSA volume
 -- lain.widgets.alsa
-local alsa = {
-    level  = "0",
-    status = "off",
-}
+local alsa = {}
 
 local function worker(args)
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 5
     local settings = args.settings or function() end
 
     alsa.cmd     = args.cmd or "amixer"
@@ -57,14 +54,8 @@ local function worker(args)
             end
         end
 
-        if alsa.level ~= volume_now.level or alsa.status ~= volume_now.status
-        then
-            widget = alsa.widget
-            settings()
-
-            alsa.level = volume_now.level
-            alsa.status = volume_now.status
-        end
+        widget = alsa.widget
+        settings()
     end
 
     timer_id = string.format("alsa-%s-%s", alsa.cmd, alsa.channel)
index fc45c726488eb82b17a6fd9d6354f4fdaee19639..c7498d2e6be2bf31fdac43ba8288e25e8d9eadfe 100644 (file)
@@ -47,8 +47,7 @@ local alsabar = {
     },
 
     _current_level = 0,
-    _muted         = false,
-    _status        = "off"
+    _muted         = false
 }
 
 function alsabar.notify()
@@ -57,7 +56,7 @@ function alsabar.notify()
     local preset = {
         title   = "",
         text    = "",
-        timeout = 1,
+        timeout = 5,
         screen  = alsabar.notifications.screen,
         font    = alsabar.notifications.font .. " " ..
                   alsabar.notifications.font_size,
@@ -95,7 +94,7 @@ end
 
 local function worker(args)
     local args       = args or {}
-    local timeout    = args.timeout or 1
+    local timeout    = args.timeout or 5
     local settings   = args.settings or function() end
     local width      = args.width or 63
     local height     = args.heigth or 1
@@ -128,33 +127,28 @@ local function worker(args)
         -- Capture mixer control state:          [5%] ... ... [on]
         local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
 
-        volu = tonumber(volu) or 0
-        if mute == "" then mute = "off"
-
-        if alsabar._current_level ~= volu or alsabar._status ~= mute then
-
-            alsabar._current_level = volu
-            alsabar._status = mute
-
-            alsabar.bar:set_value(alsabar._current_level / 100)
-
-            if not mute and volu == 0 or mute == "off"
-            then
-                alsabar._muted = true
-                alsabar.tooltip:set_text (" [Muted] ")
-                alsabar.bar:set_color(alsabar.colors.mute)
-            else
-                alsabar._muted = false
-                alsabar.tooltip:set_text(string.format(" %s:%s ", alsabar.channel, volu))
-                alsabar.bar:set_color(alsabar.colors.unmute)
-            end
-
-            volume_now = {}
-            volume_now.level = volu
-            volume_now.status = mute
+        if volu == nil then
+            volu = 0
+            mute = "off"
+        end
 
-            settings()
+        alsabar._current_level = tonumber(volu)
+        alsabar.bar:set_value(alsabar._current_level / 100)
+        if not mute and tonumber(volu) == 0 or mute == "off"
+        then
+            alsabar._muted = true
+            alsabar.tooltip:set_text (" [Muted] ")
+            alsabar.bar:set_color(alsabar.colors.mute)
+        else
+            alsabar._muted = false
+            alsabar.tooltip:set_text(string.format(" %s:%s ", alsabar.channel, volu))
+            alsabar.bar:set_color(alsabar.colors.unmute)
         end
+
+        volume_now = {}
+        volume_now.level = tonumber(volu)
+        volume_now.status = mute
+        settings()
     end
 
     alsabar.bar:buttons (awful.util.table.join (
index 88478b0512df99887d318bc26237b7c0a099d02e..2f377f78bb4ccd552bf01f5299476719f21e2d53 100644 (file)
@@ -6,7 +6,9 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
+local newtimer     = require("lain.helpers").newtimer
+local read_pipe    = require("lain.helpers").read_pipe
+
 local wibox        = require("wibox")
 
 local setmetatable = setmetatable
@@ -17,24 +19,19 @@ local setmetatable = setmetatable
 local function worker(args)
     local base     = {}
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 5
     local cmd      = args.cmd or ""
     local settings = args.settings or function() end
 
     base.widget = wibox.widget.textbox('')
-    helpers.set_map(cmd, '')
 
     function base.update()
-        output = helpers.read_pipe(cmd)
-
-        if helpers.get_map(cmd) ~= output then
-            widget = base.widget
-            settings()
-            helpers.set_map(cmd, output)
-        end
+        output = read_pipe(cmd)
+        widget = base.widget
+        settings()
     end
 
-    helpers.newtimer(cmd, timeout, base.update)
+    newtimer(cmd, timeout, base.update)
 
     return setmetatable(base, { __index = base.widget })
 end
index d18af87b35001ab4021627fc74e451902e283a8b..626239b14c28d2b32b6f1a9fc29d739e9cff5543 100644 (file)
@@ -7,7 +7,9 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
+local newtimer     = require("lain.helpers").newtimer
+local first_line   = require("lain.helpers").first_line
+
 local naughty      = require("naughty")
 local wibox        = require("wibox")
 
@@ -19,9 +21,9 @@ local setmetatable = setmetatable
 
 -- Battery infos
 -- lain.widgets.bat
+local bat = {}
 
 local function worker(args)
-    local bat = {}
     local args = args or {}
     local timeout = args.timeout or 30
     local battery = args.battery or "BAT0"
@@ -46,11 +48,6 @@ local function worker(args)
         bg = "#FFFFFF"
     }
 
-    helpers.set_map(battery .. "status", "N/A")
-    helpers.set_map(battery .. "perc", "N/A")
-    helpers.set_map(battery .. "time", "N/A")
-    helpers.set_map(battery .. "watt", "N/A")
-
     function update()
         bat_now = {
             status = "Not present",
@@ -61,22 +58,22 @@ local function worker(args)
 
         local bstr  = "/sys/class/power_supply/" .. battery
 
-        local present = helpers.first_line(bstr .. "/present")
+        local present = first_line(bstr .. "/present")
 
         if present == "1"
         then
-            local rate  = helpers.first_line(bstr .. "/power_now") or
-                          helpers.first_line(bstr .. "/current_now")
+            local rate  = first_line(bstr .. "/power_now") or
+                          first_line(bstr .. "/current_now")
 
-            local ratev = helpers.first_line(bstr .. "/voltage_now")
+            local ratev = first_line(bstr .. "/voltage_now")
 
-            local rem   = helpers.first_line(bstr .. "/energy_now") or
-                          helpers.first_line(bstr .. "/charge_now")
+            local rem   = first_line(bstr .. "/energy_now") or
+                          first_line(bstr .. "/charge_now")
 
-            local tot   = helpers.first_line(bstr .. "/energy_full") or
-                          helpers.first_line(bstr .. "/charge_full")
+            local tot   = first_line(bstr .. "/energy_full") or
+                          first_line(bstr .. "/charge_full")
 
-            bat_now.status = helpers.first_line(bstr .. "/status") or "N/A"
+            bat_now.status = first_line(bstr .. "/status") or "N/A"
 
             rate  = tonumber(rate) or 1
             ratev = tonumber(ratev)
@@ -100,7 +97,7 @@ local function worker(args)
 
             bat_now.time = string.format("%02d:%02d", hrs, min)
 
-            bat_now.perc = helpers.first_line(bstr .. "/capacity")
+            bat_now.perc = first_line(bstr .. "/capacity")
 
             if not bat_now.perc then
                 local perc = (rem / tot) * 100
@@ -118,22 +115,12 @@ local function worker(args)
             else
                 bat_now.watt = "N/A"
             end
-        end
 
-        if bat_now.status ~= helpers.get_map(battery .. "status")
-           or bat_now.perc ~= helpers.get_map(battery .. "perc")
-           or bat_now.time ~= helpers.get_map(battery .. "time")
-           or bat_now.watt ~= helpers.get_map(battery .. "watt")
-        then
-            widget = bat.widget
-            settings()
-
-            helpers.set_map(battery .. "status", bat_now.status)
-            helpers.set_map(battery .. "perc", bat_now.perc)
-            helpers.set_map(battery .. "time", bat_now.time)
-            helpers.set_map(battery .. "watt", bat_now.watt)
         end
 
+        widget = bat.widget
+        settings()
+
         -- notifications for low and critical states
         if bat_now.status == "Discharging" and notify == "on" and bat_now.perc ~= nil
         then
@@ -154,7 +141,7 @@ local function worker(args)
         end
     end
 
-    helpers.newtimer(battery, timeout, update)
+    newtimer(battery, timeout, update)
 
     return bat.widget
 end
index 15544433b91dc9c6ad751b58589072a3ff0f823e..ec84101f6d0be1bf1ed07b8b6dfe015f4b916208 100644 (file)
@@ -7,13 +7,16 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
+local first_line   = require("lain.helpers").first_line
+local newtimer     = require("lain.helpers").newtimer
+
 local wibox        = require("wibox")
 
 local math         = { ceil   = math.ceil }
 local string       = { format = string.format,
                        gmatch = string.gmatch }
 local tostring     = tostring
+
 local setmetatable = setmetatable
 
 -- CPU usage
@@ -25,18 +28,16 @@ local cpu = {
 
 local function worker(args)
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 2
     local settings = args.settings or function() end
 
     cpu.widget = wibox.widget.textbox('')
-    helpers.set_map("cpuactive", 0)
-    helpers.set_map("cputotal", 0)
 
     function update()
         -- Read the amount of time the CPUs have spent performing
         -- different kinds of work. Read the first line of /proc/stat
         -- which is the sum of all CPUs.
-        local times = helpers.first_line("/proc/stat")
+        local times = first_line("/proc/stat")
         local at = 1
         local idle = 0
         local total = 0
@@ -53,26 +54,22 @@ local function worker(args)
         end
         local active = total - idle
 
-        if helpers.get_map("cpuactive") ~= active
-           or helpers.get_map("cputotal") ~= total
-        then
-            -- Read current data and calculate relative values.
-            local dactive = active - cpu.last_active
-            local dtotal = total - cpu.last_total
+        -- Read current data and calculate relative values.
+        local dactive = active - cpu.last_active
+        local dtotal = total - cpu.last_total
 
-            cpu_now = {}
-            cpu_now.usage = tostring(math.ceil((dactive / dtotal) * 100))
+        cpu_now = {}
+        cpu_now.usage = tostring(math.ceil((dactive / dtotal) * 100))
 
-            widget = cpu.widget
-            settings()
+        widget = cpu.widget
+        settings()
 
-            -- Save current data for the next run.
-            helpers.set_map("cpuactive", active)
-            helpers.set_map("cputotal", total)
-        end
+        -- Save current data for the next run.
+        cpu.last_active = active
+        cpu.last_total = total
     end
 
-    helpers.newtimer("cpu", timeout, update)
+    newtimer("cpu", timeout, update)
 
     return cpu.widget
 end
index 8b2886b23fe1cc3688cfdc32832e6452929150ae..a1d5d95beaa896362f403a59f8c2b81cf7ce77c7 100644 (file)
@@ -26,8 +26,7 @@ local setmetatable = setmetatable
 -- File system disk space usage
 -- lain.widgets.fs
 local fs = {}
-
-local fs_notification = nil
+local fs_notification  = nil
 
 function fs:hide()
     if fs_notification ~= nil then
@@ -42,11 +41,11 @@ function fs:show(t_out)
     local ws = helpers.read_pipe(helpers.scripts_dir .. "dfs"):gsub("\n*$", "")
 
     if fs.followmouse then
-        fs_notification_preset.screen = mouse.screen
+        fs.notification_preset.screen = mouse.screen
     end
 
     fs_notification = naughty.notify({
-        preset  = fs_notification_preset,
+        preset  = fs.notification_preset,
         text    = ws,
         timeout = t_out
     })
@@ -67,7 +66,6 @@ local function worker(args)
     fs.widget = wibox.widget.textbox('')
 
     helpers.set_map(partition, false)
-    helpers.set_map("fsused", 0)
 
     function update()
         fs_info = {}
@@ -94,11 +92,8 @@ local function worker(args)
         fs_now.size_mb   = tonumber(fs_info[partition .. " size_mb"]) or 0
         fs_now.size_gb   = tonumber(fs_info[partition .. " size_gb"]) or 0
 
-        if helpers.get_map("fsused") ~= fs_now.used then
-            widget = fs.widget
-            settings()
-            helpers.set_map("fsused", fs_now.used)
-        end
+        widget = fs.widget
+        settings()
 
         if fs_now.used >= 99 and not helpers.get_map(partition)
         then
index 350e1ad3e2d1eeeff9af366192afc1a680c6aeb3..ea763dfa4127ff4baf1cdbd642b7abf61f789a1b 100644 (file)
@@ -65,10 +65,8 @@ local function worker(args)
             _, mailcount = string.gsub(f, "%d+", "")
             _ = nil
 
-            if mailcount ~= helpers.get_map(mail) then
-                widget = imap.widget
-                settings()
-            end
+            widget = imap.widget
+            settings()
 
             if mailcount >= 1 and mailcount > helpers.get_map(mail)
             then
index 8cb821dde3633fba8120a8dce30e6a71a35f759e..eed613840921ecb955ee427489323be5db989a84 100644 (file)
@@ -25,7 +25,7 @@ local setmetatable    = setmetatable
 
 -- Maildir check
 -- lain.widgets.maildir
-local maildir = { total = 0 }
+local maildir = {}
 
 local function worker(args)
     local args         = args or {}
@@ -65,7 +65,7 @@ local function worker(args)
             end
         until line == nil
 
-        p:close()
+       p:close()
         table.sort(boxes)
 
         newmail = "no mail"
@@ -88,10 +88,8 @@ local function worker(args)
             end
         end
 
-        if maildir.total ~= total then
-            widget = maildir.widget
-            settings()
-        end
+        widget = maildir.widget
+        settings()
     end
 
     newtimer(mailpath, timeout, update, true)
index dc72279d800e787ea684062d9138e0c6d7c6ab1a..f6213b236fe01483002e97f63d90da812ebdb912 100644 (file)
@@ -7,33 +7,27 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local wibox        = require("wibox")
+local newtimer        = require("lain.helpers").newtimer
 
-local io           = { lines  = io.lines }
-local math         = { floor  = math.floor }
-local string       = { gmatch = string.gmatch }
+local wibox           = require("wibox")
 
-local setmetatable = setmetatable
+local io              = { lines  = io.lines }
+local math            = { floor  = math.floor }
+local string          = { gmatch = string.gmatch }
 
--- Memory usage
+local setmetatable    = setmetatable
+
+-- Memory usage (ignoring caches)
 -- lain.widgets.mem
 local mem = {}
 
 local function worker(args)
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 2
     local settings = args.settings or function() end
 
     mem.widget = wibox.widget.textbox('')
 
-    helpers.set_map("mem_last_total", 0)
-    helpers.set_map("mem_last_free", 0)
-    helpers.set_map("mem_last_buf", 0)
-    helpers.set_map("mem_last_cache", 0)
-    helpers.set_map("mem_last_swap", 0)
-    helpers.set_map("mem_last_swapf", 0)
-
     function update()
         mem_now = {}
         for line in io.lines("/proc/meminfo")
@@ -50,29 +44,14 @@ local function worker(args)
             end
         end
 
-        if mem_now.total ~= helpers.set_map("mem_last_total")
-        or mem_now.free  ~= helpers.set_map("mem_last_free")
-        or mem_now.buf   ~= helpers.set_map("mem_last_buf")
-        or mem_now.cache ~= helpers.set_map("mem_last_cache")
-        or mem_now.swap  ~= helpers.set_map("mem_last_swap")
-        or mem_now.swapf ~= helpers.set_map("mem_last_swapf")
-        then
-            mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now.cache)
-            mem_now.swapused = mem_now.swap - mem_now.swapf
+        mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now.cache)
+        mem_now.swapused = mem_now.swap - mem_now.swapf
 
-            widget = mem.widget
-            settings()
-
-            helpers.set_map("mem_last_total", mem_now.total)
-            helpers.set_map("mem_last_free", mem_now.free)
-            helpers.set_map("mem_last_buf", mem_now.buf)
-            helpers.set_map("mem_last_cache", mem_now.cache)
-            helpers.set_map("mem_last_swap", mem_now.swap)
-            helpers.set_map("mem_last_swapf", mem_now.swapf)
-        end
+        widget = mem.widget
+        settings()
     end
 
-    helpers.newtimer("mem", timeout, update)
+    newtimer("mem", timeout, update)
 
     return mem.widget
 end
index 1d2c61737895c27c9c2d7550f3f3ad1636e6215a..5af898b482ff5dd1f97635fb5ab6e50bf004eced 100644 (file)
@@ -30,7 +30,7 @@ local mpd = {}
 
 local function worker(args)
     local args        = args or {}
-    local timeout     = args.timeout or 1
+    local timeout     = args.timeout or 2
     local password    = args.password or ""
     local host        = args.host or "127.0.0.1"
     local port        = args.port or "6600"
@@ -49,11 +49,10 @@ local function worker(args)
 
     mpd_notification_preset = {
         title   = "Now playing",
-        timeout = 5
+        timeout = 6
     }
 
-    helpers.set_map("current mpd track", "")
-    helpers.set_map("current mpd file", "")
+    helpers.set_map("current mpd track", nil)
 
     function mpd.update()
         async.request(echo .. " | curl --connect-timeout 1 -fsm 3 " .. mpdh, function (f)
@@ -72,7 +71,6 @@ local function worker(args)
                 for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do
                     if     k == "state"   then mpd_now.state   = v
                     elseif k == "file"    then mpd_now.file    = v
-                    elseif k == "Name"    then mpd_now.name    = escape_f(v)
                     elseif k == "Artist"  then mpd_now.artist  = escape_f(v)
                     elseif k == "Title"   then mpd_now.title   = escape_f(v)
                     elseif k == "Album"   then mpd_now.album   = escape_f(v)
@@ -85,13 +83,8 @@ local function worker(args)
 
             mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
                                            mpd_now.album, mpd_now.date, mpd_now.title)
-
-            if mpd_now.file ~= helpers.get_map("current mpd file")
-            then
-                widget = mpd.widget
-                settings()
-                helpers.set_map("current mpd file", mpd_now.file)
-            end
+            widget = mpd.widget
+            settings()
 
             if mpd_now.state == "play"
             then
index 983da41da0655e5a45ef366833045cda12d0fc80..a578ae4ca9cc405454c4cc57a6b23cd5a9be2a0e 100644 (file)
@@ -21,7 +21,10 @@ local setmetatable = setmetatable
 
 -- Network infos
 -- lain.widgets.net
-local net = {}
+local net = {
+    last_t = 0,
+    last_r = 0
+}
 
 function net.get_device()
     local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9")
@@ -35,7 +38,7 @@ end
 
 local function worker(args)
     local args = args or {}
-    local timeout = args.timeout or 1
+    local timeout = args.timeout or 2
     local units = args.units or 1024 --kb
     local notify = args.notify or "on"
     local screen = args.screen or 1
@@ -46,44 +49,35 @@ local function worker(args)
     net.widget = wibox.widget.textbox('')
 
     helpers.set_map(iface, true)
-    helpers.set_map("net_t", 0)
-    helpers.set_map("net_r", 0)
 
     function update()
-        net_now = {
-            sent     = "0.0",
-            received = "0.0"
-        }
+        net_now = {}
 
         if iface == "" or string.match(iface, "network off")
         then
             iface = net.get_device()
         end
 
+        net_now.carrier = helpers.first_line('/sys/class/net/' .. iface ..
+                                           '/carrier') or "0"
+        net_now.state = helpers.first_line('/sys/class/net/' .. iface ..
+                                           '/operstate') or "down"
         local now_t = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/statistics/tx_bytes') or 0
         local now_r = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/statistics/rx_bytes') or 0
 
-        if now_t ~= helpers.get_map("net_t")
-           or now_r ~= helpers.get_map("net_r") then
-            net_now.carrier = helpers.first_line('/sys/class/net/' .. iface ..
-                                           '/carrier') or "0"
-            net_now.state = helpers.first_line('/sys/class/net/' .. iface ..
-                                           '/operstate') or "down"
+        net_now.sent = (now_t - net.last_t) / timeout / units
+        net_now.sent = string.gsub(string.format('%.1f', net_now.sent), ",", ".")
 
-            net_now.sent = (now_t - net.last_t) / timeout / units
-            net_now.sent = string.gsub(string.format('%.1f', net_now.sent), ",", ".")
+        net_now.received = (now_r - net.last_r) / timeout / units
+        net_now.received = string.gsub(string.format('%.1f', net_now.received), ",", ".")
 
-            net_now.received = (now_r - net.last_r) / timeout / units
-            net_now.received = string.gsub(string.format('%.1f', net_now.received), ",", ".")
+        widget = net.widget
+        settings()
 
-            widget = net.widget
-            settings()
-
-            helpers.set_map("net_t", now_t)
-            helpers.set_map("net_r", now_r)
-        end
+        net.last_t = now_t
+        net.last_r = now_r
 
         if net_now.carrier ~= "1" and notify == "on"
         then
@@ -105,8 +99,7 @@ local function worker(args)
         end
     end
 
-    helpers.newtimer(iface, timeout, update, false)
-
+    helpers.newtimer(iface, timeout, update)
     return net.widget
 end
 
index 9472235e67d0d93d5541be48948639b76aef141a..d8e4713a77371088c2ac14693b1183b97ef4517a 100644 (file)
@@ -7,7 +7,8 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
+local newtimer     = require("lain.helpers").newtimer
+
 local wibox        = require("wibox")
 
 local io           = { open = io.open }
@@ -21,13 +22,10 @@ local sysload = {}
 
 local function worker(args)
     local args = args or {}
-    local timeout = args.timeout or 1
+    local timeout = args.timeout or 2
     local settings = args.settings or function() end
 
     sysload.widget = wibox.widget.textbox('')
-    helpers.set_map("load_1", 0)
-    helpers.set_map("load_5", 0)
-    helpers.set_map("load_15", 0)
 
     function update()
         local f = io.open("/proc/loadavg")
@@ -36,21 +34,11 @@ local function worker(args)
 
         load_1, load_5, load_15 = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
 
-        if load_1 ~= helpers.get_map("load_1")
-           or load_5 ~= helpers.get_map("load_5")
-           or load_15 ~= helpers.get_map("load_15")
-        then
-            widget = sysload.widget
-            settings()
-
-            helpers.set_map("load_1", load_1)
-            helpers.set_map("load_5", load_5)
-            helpers.set_map("load_15", load_15)
-        end
+        widget = sysload.widget
+        settings()
     end
 
-    helpers.newtimer("sysload", timeout, update)
-
+    newtimer("sysload", timeout, update)
     return sysload.widget
 end
 
index 6831588f3e7714d330c55dba73412331d327c233..67c94560b9a58e67fa15ef340c8862f4b473e020 100644 (file)
@@ -6,7 +6,8 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
+local newtimer     = require("lain.helpers").newtimer
+
 local wibox        = require("wibox")
 
 local io           = { open = io.open }
@@ -20,12 +21,11 @@ local temp = {}
 
 local function worker(args)
     local args     = args or {}
-    local timeout  = args.timeout or 1
+    local timeout  = args.timeout or 2
     local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
     local settings = args.settings or function() end
 
     temp.widget = wibox.widget.textbox('')
-    helpers.set_map("temp_last", 0)
 
     function update()
         local f = io.open(tempfile)
@@ -37,15 +37,11 @@ local function worker(args)
             coretemp_now = "N/A"
         end
 
-        if helpers.get_map("temp_last") ~= coretemp_now then
-            widget = temp.widget
-            settings()
-            helpers.set_map("temp_last", coretemp_now)
-        end
+        widget = temp.widget
+        settings()
     end
 
-    helpers.newtimer("coretemp", timeout, update)
-
+    newtimer("coretemp", timeout, update)
     return temp.widget
 end