From e4c5d756c98141bfeeeda7a75be33b87ccca6a26 Mon Sep 17 00:00:00 2001 From: luke bonham 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 zcmV+b1^@bqP)WFU8GbZ8()Nlj2>E@cM*00d-7L_t(I%XL&;XcSiz z{?5HSJIN&3S=Oz)M7Bw65K{%U4~A|^9$L~C3|O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;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>`_MtsRmn4(Hs< zRq5)ycV~;D*aP74;" .. f:read() .. "\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 = "" + .. f:read("*all"):gsub("\n*$", "") + .. "" + 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" + .. f:read("*all") + .. "" + + 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 = "" + .. c_text .. "\n" + .. "" + 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 = "Tasks next\n" - .. "" - .. f:read("*all") .. "\n" - .. "" - 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 = "" - .. f:read("*all") .. "\n" - .. "" - - 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 = "" - .. f:read("*all") .. "\n" - .. "" - - 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