]> 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:

Merge branch 'master' of https://github.com/copycat-killer/lain
authoraajjbb <jefersonlsiq@gmail.com>
Sat, 2 Jan 2016 20:16:02 +0000 (18:16 -0200)
committeraajjbb <jefersonlsiq@gmail.com>
Sat, 2 Jan 2016 20:16:02 +0000 (18:16 -0200)
helpers.lua
widgets/maildir.lua
widgets/mpd.lua
widgets/net.lua
wiki

index 4e90e169c15a570bb31aa4c6fa3f1ac9e70c5336..4ece329a6dc886f4e106ceb2711d1589a0a99334 100644 (file)
@@ -13,6 +13,7 @@ local io     = { open  = io.open,
                  lines = io.lines,
                  popen = io.popen }
 local rawget = rawget
+local table  = { sort   = table.sort }
 
 -- Lain helper functions for internal use
 -- lain.helpers
@@ -113,4 +114,23 @@ end
 
 -- }}}
 
+--{{{ Iterate over table of records sorted by keys
+function helpers.spairs(t)
+    -- collect the keys
+    local keys = {}
+    for k in pairs(t) do keys[#keys+1] = k end
+
+    table.sort(keys)
+
+    -- return the iterator function
+    local i = 0
+    return function()
+        i = i + 1
+        if keys[i] then
+            return keys[i], t[keys[i]]
+        end
+    end
+end
+--}}}
+
 return helpers
index eed613840921ecb955ee427489323be5db989a84..c9937b47e0d2f4d2eb15a00cc945aab6e8920b4b 100644 (file)
@@ -9,9 +9,11 @@
 
 local newtimer        = require("lain.helpers").newtimer
 local read_pipe       = require("lain.helpers").read_pipe
+local spairs          = require("lain.helpers").spairs
 
 local wibox           = require("wibox")
 
+local awful           = require("awful")
 local util            = require("lain.util")
 
 local io              = { popen  = io.popen }
@@ -19,7 +21,6 @@ local os              = { getenv = os.getenv }
 local pairs           = pairs
 local string          = { len    = string.len,
                           match  = string.match }
-local table           = { sort   = table.sort }
 
 local setmetatable    = setmetatable
 
@@ -33,13 +34,19 @@ local function worker(args)
     local mailpath     = args.mailpath or os.getenv("HOME") .. "/Mail"
     local ignore_boxes = args.ignore_boxes or {}
     local settings     = args.settings or function() end
+    local ext_mail_cmd = args.external_mail_cmd
 
     maildir.widget = wibox.widget.textbox('')
 
     function update()
+        if ext_mail_cmd ~= nil
+        then
+            awful.util.spawn(ext_mail_cmd)
+        end
+
         -- Find pathes to mailboxes.
         local p = io.popen("find " .. mailpath ..
-                           " -mindepth 1 -maxdepth 1 -type d" ..
+                           " -mindepth 1 -maxdepth 2 -type d" ..
                            " -not -name .git")
         local boxes = {}
         repeat
@@ -56,7 +63,7 @@ local function worker(args)
                                     "-not -name '.*' -printf a")
 
                 -- Strip off leading mailpath.
-                local box = string.match(line, mailpath .. "/*([^/]+)")
+                local box = string.match(line, mailpath .. "/(.*)")
                 local nummails = string.len(mailstring)
                 if nummails > 0
                 then
@@ -65,14 +72,13 @@ local function worker(args)
             end
         until line == nil
 
-       p:close()
-        table.sort(boxes)
+        p:close()
 
         newmail = "no mail"
         -- Count the total number of mails irrespective of where it was found
         total = 0
 
-        for box, number in pairs(boxes)
+        for box, number in spairs(boxes)
         do
             -- Add this box only if it's not to be ignored.
             if not util.element_in_table(box, ignore_boxes)
index 5af898b482ff5dd1f97635fb5ab6e50bf004eced..19720509c8d247a955aad076360974ef22841d92 100644 (file)
@@ -59,6 +59,7 @@ local function worker(args)
             mpd_now = {
                 state   = "N/A",
                 file    = "N/A",
+                name    = "N/A",
                 artist  = "N/A",
                 title   = "N/A",
                 album   = "N/A",
@@ -71,6 +72,7 @@ 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)
index a578ae4ca9cc405454c4cc57a6b23cd5a9be2a0e..af823a824e1eaa48e8e5bd05025365c7d46f261a 100644 (file)
@@ -21,30 +21,27 @@ local setmetatable = setmetatable
 
 -- Network infos
 -- lain.widgets.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")
-    ws = ws:match("%w+: UP") or ws:match("ppp%w+: UNKNOWN")
-    if ws ~= nil then
-        return ws:match("(%w+):")
-    else
-        return "network off"
-    end
-end
 
 local function worker(args)
-    local args = args or {}
-    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
-    local settings = args.settings or function() end
+    local net = { last_t = 0, last_r = 0 }
 
-    iface = args.iface or net.get_device()
+    function net.get_device()
+        local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9")
+        ws = ws:match("%w+: UP") or ws:match("ppp%w+: UNKNOWN")
+        if ws ~= nil then
+            return ws:match("(%w+):")
+        else
+            return "network off"
+        end
+    end
+
+    local args     = args or {}
+    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
+    local settings = args.settings or function() end
+    local iface    = args.iface or net.get_device()
 
     net.widget = wibox.widget.textbox('')
 
@@ -100,7 +97,8 @@ local function worker(args)
     end
 
     helpers.newtimer(iface, timeout, update)
-    return net.widget
+
+    return setmetatable(net, { __index = net.widget })
 end
 
-return setmetatable(net, { __call = function(_, ...) return worker(...) end })
+return setmetatable({}, { __call = function(_, ...) return worker(...) end })
diff --git a/wiki b/wiki
index 35cc75dcb382fccdec6941698a1e96cc875fae1f..cefdc887c46f0f7c5d837d1449927e7dbf66b19e 160000 (submodule)
--- a/wiki
+++ b/wiki
@@ -1 +1 @@
-Subproject commit 35cc75dcb382fccdec6941698a1e96cc875fae1f
+Subproject commit cefdc887c46f0f7c5d837d1449927e7dbf66b19e