From e4c5d756c98141bfeeeda7a75be33b87ccca6a26 Mon Sep 17 00:00:00 2001
From: luke bonham <dadasignificanulla@gmail.com>
Date: Wed, 25 Sep 2013 15:08:11 +0200
Subject: [PATCH] contrib section started\!

---
 README.rst                      |  17 +++++
 icons/taskwarrior.png           | Bin 1280 -> 0 bytes
 icons/taskwarrior/task.png      | Bin 0 -> 1212 bytes
 icons/taskwarrior/tasksmall.png | Bin 0 -> 941 bytes
 widgets/calendar.lua            |   1 -
 widgets/contrib/init.lua        |  20 +++++
 widgets/contrib/task.lua        | 131 ++++++++++++++++++++++++++++++++
 widgets/mpd.lua                 |   2 +-
 widgets/task.lua                | 124 ------------------------------
 wiki                            |   2 +-
 10 files changed, 170 insertions(+), 127 deletions(-)
 delete mode 100644 icons/taskwarrior.png
 create mode 100644 icons/taskwarrior/task.png
 create mode 100755 icons/taskwarrior/tasksmall.png
 create mode 100644 widgets/contrib/init.lua
 create mode 100644 widgets/contrib/task.lua
 delete mode 100644 widgets/task.lua

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 171af60260bcba14cafa18f1530935841d6f38b4..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1280
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E7x_a*Tyn45fKZ^vfOMoOXVaHA(2Q-u84LK
zk;BaKojZ5_1OSF%Oso|&P4kJAa)U5Ua}<CqCvDrt@bK`!+9Lb*?UMlD^?JuF%X*C~
z6bd<Jek2UTxWdeu>$>?8naky#ba!_r*R-^H&SWwv$8jE)xid6PdpDIz^$6E>Z`!u~
z+%(NuA_6l*)3myW4<G)p)?r^?p9R3PZr!?WMN#TYTrQXUhluo+mX==8+S>ZU<MG@~
zBogDcZ5N0LQcC#!{?2$jKD>Yb{=kaE;`#IEKbW4Lj_JC7SV}1Xz_Ki(P$(2$zI=Hc
z0GB>POifLVEG#Tc)YaAPRTRZnwgBMudf~b*Gc!pk%ilWl^y$;SU@%D6u3h_D(==ON
zy?Pb>{r$YKu+Z1u-o7`R%@!QTnfG`+>*XtyS|%wagb=W8JD161?q@QY*_xV~^ySN!
zzd3Q@gn8q}jaTbyaBvX2ckf0|Pfx|xty}l{{r>NY#p0tvq3}Y}wA$+G>M#H{3}ZHz
z%Pm$`R&F4o(DL%~@v*V7>z$pQ_R!D}+S=McZ<%TD=;-M2Kp@b;%swH+la<}sNJR6=
qWb#5Z8vPkS@$A{NICA93YT|!n4<XE&6@Y&L0000<MNUMnLSTY88DH@L

diff --git a/icons/taskwarrior/task.png b/icons/taskwarrior/task.png
new file mode 100644
index 0000000000000000000000000000000000000000..859ca29120f197ef2f46a76baefd7b5cd81c58c1
GIT binary patch
literal 1212
zcmV;t1Vj6YP)<h;3K|Lk000e1NJLTq002e+002e^1^@s6aW3M700006VoOIv0RI60
z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3b{B0x>PfQfvSK1W8Fm
zK~#9!?VL?k8%Gew|J9CJ+S=62!VAF(Bu=2=0!CaQA146k0ud*$IYAz|05TT{oPf~@
zA{JT9^dd4#ExNMM$QF9U8M=FVdU&dx^pLvvsj9lVs(OH(JSo)1qD7&HN?{Dhfe7^h
z91`Kp)}P&rU`{0W0OiKu&ot%y#erGDkPjj>egZ-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34YxGqMUrp^;G#t?=SjlH(OoZISr4B9auPD`tk#kfW}bM<l$%hLIhlrv
zJJrK4`nDrwLBXu!4l@q{oHu7B_%%s5^Zme!M!{^j)&y7{_zcV<xF%W-m>*Awb_&ee
zdXj`QV{nAkEUvZN7=xoE;p3(UAeGkTt588QP5FkI_l?1k2(D{>><b`&R6w$(9;CCA
an({9?3hMu2fmuKR0000<MNUMnLSTZQT_4K;

literal 0
HcmV?d00001

diff --git a/icons/taskwarrior/tasksmall.png b/icons/taskwarrior/tasksmall.png
new file mode 100755
index 0000000000000000000000000000000000000000..2de6946550635bd442ee57f9b4db65e17168f8d0
GIT binary patch
literal 941
zcmV;e15*5nP)<h;3K|Lk000e1NJLTq001Ze001Zm1^@s6jQ+T700006VoOIv0RI60
z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3b{A7!E2y@4Wy313F1W
zK~z}7%~;QCR96)Kz85E{sc7xJH&QpX0a1t%iCC=xrIbP|;=U^t40Y>5>B4O(ZlrW$
z&7$Dazd+Z;l~#rLV^K;#3pUO>m!Mz_lDw~rnTez3$Gn+4Ne*0?_wIY=e($^Yob#Qb
zBs46>$oY9;V8Fk<xyH7k@x#pM{rUmcFg7#Tj+w<lK>Gj=k;nkdO8Q6Q?GW6*YX;CP
zUIg?LiH`v;+?N0n00arI0RG~=`+3y>=6T$iWw--iONrNBNyQQG!@aTqvy!as%`*Hg
zVROlK`ho0jp4-u`F&N{2JwRm!U<J*4+M-Di2}=0Hd-ozagHrDw0D9X22LL1pK%}lG
zXE4TRJyPEsnJRe{JDdwok})Xt{Ya)uky196dW(;@xwA{ziPQl1C9Mv`a8iIIK3l6&
zmtmb-i$Rih(K7y8W$+px0GN<4Sr)JaNSFjLQTKDLwA@<$3>Lou*+~gkym!CXYw{q8
zAprXUi~!gTU@L%WKo0;u0B~2rqY&I=y;Pnhd8OvB<*!pqBhPc0<>ReBzt}L#$IVP-
z-YF3ztV$e<(Jr)e?qam_62~M=x233CIj^-+$4h2*f_!ttx$VWuz@~bo%AWual7NKy
zZlxJD<;BBN-^&>D;T7cBs8o4P>dU4&{!v!|k_ydNB>JUnB1SvE1h~s2Zq-!GJ2GQa
zay2tG^=xCM(l@iz{M;M{wrz8HQ+GHD;MS5_rYJrSAv{gSV5QP~Xoc^1e|CPkN6Bm`
zaV6n_baIOTG@4i}=)071i^MmHgM?ovZpRNL188QW=z^KWZ<7EdaYjN?JyYxO^g|MW
z5>Iu5L5Zgm0mS#Ue3^#Dx*yj4b`CHEcT>`_Mt<lNUme`B5ZujVQ5=H5K^7xYM<6Ak
z05BYayOF#WI~VSg@RFXigHh5`5}$hS9(Jv1a?VBX{TC9iHl3$s&s$CI>sRmn4(Hs<
zRq5)ycV~;D*aP74;<b3;@-L~_<-I@GK~xEOp0iyUU#;3#&!5|-ccr~;&-3a?C+$IF
zEXb|(`X6=ncH6vSj9e=q)v9r^^*<1-F&ZVpd$($An#Fzqh4*gu{ki`E+JjAtmp&Bb
P00000NkvXXu0mjffc&-Z

literal 0
HcmV?d00001

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
-- 
2.39.5