contrib section started\!

This commit is contained in:
luke bonham 2013-09-25 15:08:11 +02:00
parent ea784d4c84
commit e4c5d756c9
10 changed files with 170 additions and 127 deletions

View File

@ -19,6 +19,23 @@ in order to improve Awesome_ usability and configurability.
Read the wiki_ for all the info. 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 Screenshots
----------- -----------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
icons/taskwarrior/task.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/taskwarrior/tasksmall.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

View File

@ -86,7 +86,6 @@ function calendar:show(t_out, inc_offset)
f = io.popen('/usr/bin/cal ' .. month .. ' ' .. year) f = io.popen('/usr/bin/cal ' .. month .. ' ' .. year)
end end
c_text = "<tt><span font='" .. font .. " " c_text = "<tt><span font='" .. font .. " "
.. calendar.font_size .. "'><b>" .. calendar.font_size .. "'><b>"
.. f:read() .. "</b>\n\n" .. f:read() .. "</b>\n\n"

20
widgets/contrib/init.lua Normal file
View File

@ -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 })

131
widgets/contrib/task.lua Normal file
View File

@ -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 })

View File

@ -28,7 +28,7 @@ local mpd = {}
local function worker(args) local function worker(args)
local args = args or {} local args = args or {}
local timeout = args.timeout or 2 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 host = args.host or "127.0.0.1"
local port = args.port or "6600" local port = args.port or "6600"
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"

View File

@ -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 })

2
wiki

@ -1 +1 @@
Subproject commit 476e9f57bb66cec635ce61170a57f49299e6c715 Subproject commit 91217d6bad68401ee926ca79d3ef917525507321