From: aajjbb Date: Sun, 11 Oct 2015 21:05:21 +0000 (-0300) Subject: Merge branch 'master' of https://github.com/copycat-killer/lain X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/1a8ddf0e7fd88ec6f71c1a59aa4b2602c12cec50?hp=69ddbc74a59ead7b3c140d42d94cb39d574284fa Merge branch 'master' of https://github.com/copycat-killer/lain --- diff --git a/widgets/contrib/init.lua.orig b/widgets/contrib/init.lua.orig new file mode 100644 index 0000000..3ad0835 --- /dev/null +++ b/widgets/contrib/init.lua.orig @@ -0,0 +1,23 @@ + +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Users contributed widgets section + + Licensed under GNU General Public License v2 +<<<<<<< HEAD + * (c) 2013, Luke Bonham +======= + * (c) 2013, Luke Bonham +>>>>>>> upstream/master + +--]] + +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/moc.lua.orig b/widgets/contrib/moc.lua.orig new file mode 100644 index 0000000..fb8afec --- /dev/null +++ b/widgets/contrib/moc.lua.orig @@ -0,0 +1,117 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2014, anticlockwise + +--]] + +local helpers = require("lain.helpers") +local async = require("lain.asyncshell") + +local escape_f = require("awful.util").escape +local naughty = require("naughty") +local wibox = require("wibox") + +local io = { popen = io.popen } +local os = { execute = os.execute, + getenv = os.getenv } +local string = { format = string.format, + gmatch = string.gmatch } + +local setmetatable = setmetatable + +local moc = {} + +local function worker(args) + local args = args or {} + local timeout = args.timeout or 2 + local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" + local cover_size = args.cover_size or 100 + local default_art = args.default_art or "" +<<<<<<< HEAD +======= + local followmouse = args.followmouse or false +>>>>>>> upstream/master + local settings = args.settings or function() end + + local mpdcover = helpers.scripts_dir .. "mpdcover" + + moc.widget = wibox.widget.textbox('') + + moc_notification_preset = { + title = "Now playing", + timeout = 6 + } + + helpers.set_map("current moc track", nil) + + function moc.update() + -- mocp -i will produce output like: + -- Artist: Travis + -- Album: The Man Who + -- etc. + async.request("mocp -i", function(f) + moc_now = { + state = "N/A", + file = "N/A", + artist = "N/A", + title = "N/A", + album = "N/A", + elapsed = "N/A", + total = "N/A" + } + +<<<<<<< HEAD + for line in f:lines() do +======= + for line in string.gmatch(f, "[^\n]+") do +>>>>>>> upstream/master + for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do + if k == "State" then moc_now.state = v + elseif k == "File" then moc_now.file = v + elseif k == "Artist" then moc_now.artist = escape_f(v) + elseif k == "SongTitle" then moc_now.title = escape_f(v) + elseif k == "Album" then moc_now.album = escape_f(v) + elseif k == "CurrentTime" then moc_now.elapsed = escape_f(v) + elseif k == "TotalTime" then moc_now.total = escape_f(v) + end + end + end + + moc_notification_preset.text = string.format("%s (%s) - %s\n%s", moc_now.artist, + moc_now.album, moc_now.total, moc_now.title) + widget = moc.widget + settings() + + if moc_now.state == "PLAY" then + if moc_now.title ~= helpers.get_map("current moc track") then + helpers.set_map("current moc track", moc_now.title) + os.execute(string.format("%s %q %q %d %q", mpdcover, "", + moc_now.file, cover_size, default_art)) + +<<<<<<< HEAD +======= + if followmouse then + moc_notification_preset.screen = mouse.screen + end + +>>>>>>> upstream/master + moc.id = naughty.notify({ + preset = moc_notification_preset, + icon = "/tmp/mpdcover.png", + replaces_id = moc.id, + }).id + end + elseif moc_now.state ~= "PAUSE" then + helpers.set_map("current moc track", nil) + end + end) + end + + helpers.newtimer("moc", timeout, moc.update) + + return setmetatable(moc, { __index = moc.widget }) +end + +return setmetatable(moc, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/contrib/task.lua.orig b/widgets/contrib/task.lua.orig new file mode 100644 index 0000000..d84e55f --- /dev/null +++ b/widgets/contrib/task.lua.orig @@ -0,0 +1,176 @@ + +--[[ + + 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") + +<<<<<<< HEAD +======= +local mouse = mouse +>>>>>>> upstream/master +local io = io +local string = { len = string.len } +local tonumber = tonumber + +local setmetatable = setmetatable + +-- Taskwarrior notification +-- lain.widgets.contrib.task +local task = {} + +local task_notification = nil + +function task:hide() + if task_notification ~= nil then + naughty.destroy(task_notification) + task_notification = nil + end +end + +<<<<<<< HEAD +function task:show() +======= +function task:show(scr_pos) +>>>>>>> upstream/master + task:hide() + + local f, c_text + +<<<<<<< HEAD +======= + if task.followmouse then + local scrp = mouse.screen + else + local scrp = scr_pos or task.scr_pos + end + +>>>>>>> upstream/master + 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, +<<<<<<< HEAD +======= + screen = scrp +>>>>>>> upstream/master + }) +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") + .. "" + f:close() + + 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"):gsub(" \n*$", "") + f:close() + + if string.len(c_text) == 0 + then + c_text = "No results found." + else + c_text = "" + .. c_text + .. "" + end + + naughty.notify({ + title = "[task next " .. ... .. "]", + text = c_text, + icon = task.notify_icon, + position = task.position, + fg = task.fg, + bg = task.bg, + timeout = task.timeout, +<<<<<<< HEAD +======= + screen = mouse.screen +>>>>>>> upstream/master + }) + end, + nil, + awful.util.getdir("cache") .. "/history_task") +end + +function task:attach(widget, args) +<<<<<<< HEAD + 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 +======= + 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.scr_pos = args.scr_pos or 1 + task.followmouse = args.followmouse or false +>>>>>>> upstream/master + + task.notify_icon = icons_dir .. "/taskwarrior/task.png" + task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png" + +<<<<<<< HEAD + widget:connect_signal("mouse::enter", function () task:show() end) +======= + widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end) +>>>>>>> upstream/master + widget:connect_signal("mouse::leave", function () task:hide() end) +end + +return setmetatable(task, { __call = function(_, ...) return create(...) end })