From: luke bonham <dadasignificanulla@gmail.com>
Date: Wed, 25 Sep 2013 13:08:11 +0000 (+0200)
Subject: contrib section started\!
X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/e4c5d756c98141bfeeeda7a75be33b87ccca6a26?ds=sidebyside

contrib section started\!
---

diff --git a/README.rst b/README.rst
index 779428d..66d846c 100644
--- a/README.rst
+++ b/README.rst
@@ -19,6 +19,23 @@ in order to improve Awesome_ usability and configurability.
 
 Read the wiki_ for all the info.
 
+Contributions
+-------------
+
+Any contribution is welcome! Feel free to make a pull request.
+
+Just make sure that:
+
+- Your code fits with the general style of the module. In particular, you should use the same indentation pattern that the code uses, and also avoid adding space at the ends of lines.
+
+- Your code its easy to understand, maintainable, and modularized. You should also avoid code duplication wherever possible by adding functions or using `lain.helpers`. If something is unclear, and you can't write it in such a way that it will be clear, explain it with a comment.
+
+- You test your changes before submitting to make sure that not only your code work, but have not broken other parts of the module too!
+
+- You update `wiki` submodule with a thorough section.
+
+Contributed widgets have to be put it in `lain/widget/contrib`.
+
 Screenshots
 -----------
 
diff --git a/icons/taskwarrior.png b/icons/taskwarrior.png
deleted file mode 100644
index 171af60..0000000
Binary files a/icons/taskwarrior.png and /dev/null differ
diff --git a/icons/taskwarrior/task.png b/icons/taskwarrior/task.png
new file mode 100644
index 0000000..859ca29
Binary files /dev/null and b/icons/taskwarrior/task.png differ
diff --git a/icons/taskwarrior/tasksmall.png b/icons/taskwarrior/tasksmall.png
new file mode 100755
index 0000000..2de6946
Binary files /dev/null and b/icons/taskwarrior/tasksmall.png differ
diff --git a/widgets/calendar.lua b/widgets/calendar.lua
index 57fadd9..8c707c8 100644
--- a/widgets/calendar.lua
+++ b/widgets/calendar.lua
@@ -86,7 +86,6 @@ function calendar:show(t_out, inc_offset)
        f = io.popen('/usr/bin/cal ' .. month .. ' ' .. year)
     end
 
-
     c_text = "<tt><span font='" .. font .. " "
              .. calendar.font_size .. "'><b>"
              .. f:read() .. "</b>\n\n"
diff --git a/widgets/contrib/init.lua b/widgets/contrib/init.lua
new file mode 100644
index 0000000..81321c6
--- /dev/null
+++ b/widgets/contrib/init.lua
@@ -0,0 +1,20 @@
+
+--[[
+                                                   
+     Lain                                          
+     Layouts, widgets and utilities for Awesome WM 
+                                                   
+     User contributed widgets section              
+                                                   
+     Licensed under GNU General Public License v2  
+      * (c) 2013,      Luke Bonham                 
+      * (c) 2010-2012, Peter Hofmann               
+                                                   
+--]]
+
+local wrequire     = require("lain.helpers").wrequire
+local setmetatable = setmetatable
+
+local widgets = { _NAME = "lain.widgets.contrib" }
+
+return setmetatable(widgets, { __index = wrequire })
diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua
new file mode 100644
index 0000000..88baa71
--- /dev/null
+++ b/widgets/contrib/task.lua
@@ -0,0 +1,131 @@
+
+--[[
+                                                  
+     Licensed under GNU General Public License v2 
+      * (c) 2013, Luke Bonham                     
+      * (c) 2013, Jan Xie                         
+                                                  
+--]]
+
+local icons_dir    = require("lain.helpers").icons_dir
+
+local awful        = require("awful")
+local beautiful    = require("beautiful")
+local naughty      = require("naughty")
+
+local io           = io
+local string       = { len = string.len }
+local tonumber     = tonumber
+
+local setmetatable = setmetatable
+
+-- Taskwarrior notification
+-- lain.widgets.task
+local task = {}
+
+local task_notification = nil
+
+function task:hide()
+    if task_notification ~= nil then
+        naughty.destroy(task_notification)
+        task_notification = nil
+    end
+end
+
+function task:show()
+    task:hide()
+
+    local f, c_text
+
+    f = io.popen('task')
+    c_text = "<tt><span font='"
+             .. task.font .. " "
+             .. task.font_size .. "'>"
+             .. f:read("*all"):gsub("\n*$", "")
+             .. "</span></tt>"
+    f:close()
+
+    task_notification = naughty.notify({ title = "[task next]",
+                                         text = c_text,
+                                         icon = task.notify_icon,
+                                         position = task.position,
+                                         fg = task.fg,
+                                         bg = task.bg,
+                                         timeout = task.timeout })
+end
+
+function task:prompt_add()
+  awful.prompt.run({ prompt = "Add task: " },
+      mypromptbox[mouse.screen].widget,
+      function (...)
+          local f = io.popen("task add " .. ...)
+          c_text = "\n<tt><span font='" 
+                   .. task.font .. " "
+                   .. task.font_size .. "'>"
+                   .. f:read("*all")
+                   .. "</span></tt>"
+
+          naughty.notify({
+              text = c_text,
+              icon = task.notify_icon,
+              position = task.position,
+              fg = task.fg,
+              bg = task.bg,
+              timeout = task.timeout
+          })
+      end,
+      nil,
+      awful.util.getdir("cache") .. "/history_task_add")
+end
+
+function task:prompt_search()
+  awful.prompt.run({ prompt = "Search task: " },
+      mypromptbox[mouse.screen].widget,
+      function (...)
+          local f = io.popen("task " .. ...)
+          c_text = f:read("*all")
+          f:close()
+
+          if string.len(c_text) == 0
+          then
+              c_text = "No results found."
+          else
+              c_text = "<tt><span font='"
+                       .. task.font .. " "
+                       .. task.font_size .. "'>"
+                       .. c_text .. "\n"
+                       .. "</span></tt>"
+          end
+
+          naughty.notify({
+              text = c_text,
+              icon = task.notify_icon,
+              position = task.position,
+              fg = task.fg,
+              bg = task.bg,
+              timeout = task.timeout
+          })
+      end,
+      nil,
+      awful.util.getdir("cache") .. "/history_task")
+end
+
+function task:attach(widget, args)
+    local args     = args or {}
+
+    task.font_size = tonumber(args.font_size) or 12
+    task.font      = beautiful.font:sub(beautiful.font:find(""),
+                     beautiful.font:find(" "))
+    task.fg        = args.fg or beautiful.fg_normal or "#FFFFFF"
+    task.bg        = args.bg or beautiful.bg_normal or "#FFFFFF"
+    task.position  = args.position or "top_right"
+    task.timeout   = args.timeout or 7
+
+    task.notify_icon = icons_dir .. "/taskwarrior/task.png"
+    task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png"
+
+    widget:connect_signal("mouse::enter", function () task:show() end)
+    widget:connect_signal("mouse::leave", function () task:hide() end)
+end
+
+return setmetatable(task, { __call = function(_, ...) return create(...) end })
diff --git a/widgets/mpd.lua b/widgets/mpd.lua
index 41233cd..e3ed50d 100644
--- a/widgets/mpd.lua
+++ b/widgets/mpd.lua
@@ -28,7 +28,7 @@ local mpd = {}
 local function worker(args)
     local args        = args or {}
     local timeout     = args.timeout or 2
-    local password    = args.password or ""
+    local password    = args.password or "\"\""
     local host        = args.host or "127.0.0.1"
     local port        = args.port or "6600"
     local music_dir   = args.music_dir or os.getenv("HOME") .. "/Music"
diff --git a/widgets/task.lua b/widgets/task.lua
deleted file mode 100644
index f2b49f4..0000000
--- a/widgets/task.lua
+++ /dev/null
@@ -1,124 +0,0 @@
-
---[[
-                                                  
-     Licensed under GNU General Public License v2 
-      * (c) 2013, Jan Xie
-                                                  
---]]
-
-local icons_dir    = require("lain.helpers").icons_dir
-
-local awful        = require("awful")
-local beautiful    = require("beautiful")
-local naughty      = require("naughty")
-
-local io           = io
-local tonumber     = tonumber
-
-local setmetatable = setmetatable
-
--- task notification
--- lain.widgets.task
-local task = {}
-local task_notification = nil
-
-function task:hide()
-    if task_notification ~= nil then
-        naughty.destroy(task_notification)
-        task_notification = nil
-    end
-end
-
-function task:show()
-    task:hide()
-
-    local f, c_text
-
-    f = io.popen('task')
-    c_text = "<tt><span font='" .. task.font .. " "
-             .. task.font_size+2 .. "'><b>Tasks next</b></span>\n"
-             .. "<span font='" .. task.font .. " "
-             .. task.font_size .. "'>"
-             .. f:read("*all") .. "\n"
-             .. "</span></tt>"
-    f:close()
-
-    task_notification = naughty.notify({ text = c_text,
-                                        icon = task.notify_icon,
-                                        position = task.position,
-                                        fg = task.fg,
-                                        bg = task.bg,
-                                        timeout = task.timeout })
-end
-
-function task:add(...)
-  local f = io.popen("task add " .. ...)
-  c_text = "<tt><span font='" .. task.font .. " "
-           .. task.font_size .. "'>"
-           .. f:read("*all") .. "\n"
-           .. "</span></tt>"
-
-  naughty.notify({ text = c_text,
-                   icon = task.notify_icon,
-                   position = task.position,
-                   fg = task.fg,
-                   bg = task.bg,
-                   timeout = task.timeout})
-end
-
-function task:prompt_add()
-  awful.prompt.run( { prompt = "Add task: " },
-                    mypromptbox[mouse.screen].widget,
-                    function (...)
-                      task:add(...)
-                    end,
-                    nil,
-                    awful.util.getdir("cache") .. "/history_task_add")
-end
-
-function task:execute(...)
-  local f = io.popen("task " .. ...)
-  c_text = "<tt><span font='" .. task.font .. " "
-           .. task.font_size .. "'>"
-           .. f:read("*all") .. "\n"
-           .. "</span></tt>"
-
-  naughty.notify({ text = c_text,
-                   icon = task.notify_icon,
-                   position = task.position,
-                   fg = task.fg,
-                   bg = task.bg,
-                   timeout = task.timeout})
-end
-
-function task:prompt()
-  awful.prompt.run( { prompt = "Task: " },
-                    mypromptbox[mouse.screen].widget,
-                    function (...)
-                      task:execute(...)
-                    end,
-                    nil,
-                    awful.util.getdir("cache") .. "/history_task")
-end
-
-function task:attach(widget, args)
-    local args = args or {}
-    task.font_size = tonumber(args.font_size) or 12
-    task.font = beautiful.font:sub(beautiful.font:find(""),
-                beautiful.font:find(" "))
-    task.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
-    task.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
-    task.position = args.position or "top_right"
-    task.timeout = args.timeout or 7
-
-    task.notify_icon = icons_dir .. "taskwarrior.png"
-
-    widget:connect_signal("mouse::enter", function () task:show() end)
-    widget:connect_signal("mouse::leave", function () task:hide() end)
-    widget:buttons(awful.util.table.join( awful.button({ }, 1, function ()
-                                              task:show(0, -1) end),
-                                          awful.button({ }, 3, function ()
-                                              task:show(0, 1) end) ))
-end
-
-return setmetatable(task, { __call = function(_, ...) return create(...) end })
diff --git a/wiki b/wiki
index 476e9f5..91217d6 160000
--- a/wiki
+++ b/wiki
@@ -1 +1 @@
-Subproject commit 476e9f57bb66cec635ce61170a57f49299e6c715
+Subproject commit 91217d6bad68401ee926ca79d3ef917525507321