2009-02-27 17:22:03 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008-2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
local util = require("awful.util")
|
2009-04-17 18:08:52 +02:00
|
|
|
local wbutton = require("awful.widget.button")
|
|
|
|
local button = require("awful.button")
|
2009-02-27 17:22:03 +01:00
|
|
|
|
|
|
|
module("awful.widget.launcher")
|
|
|
|
|
|
|
|
--- Create a button widget which will launch a command.
|
|
|
|
-- @param args Standard widget table arguments, plus image for the image path
|
|
|
|
-- and command for the command to run on click, or either menu to create menu.
|
|
|
|
-- @return A launcher widget.
|
2009-04-27 21:55:41 +02:00
|
|
|
function new(args)
|
2009-02-27 17:22:03 +01:00
|
|
|
if not args.command and not args.menu then return end
|
2009-04-17 18:08:52 +02:00
|
|
|
local w = wbutton(args)
|
2009-02-27 17:22:03 +01:00
|
|
|
if not w then return end
|
|
|
|
|
|
|
|
if args.command then
|
2009-08-14 16:46:35 +02:00
|
|
|
b = util.table.join(w:buttons(), button({}, 1, nil, function () util.spawn(args.command) end))
|
2009-02-27 17:22:03 +01:00
|
|
|
elseif args.menu then
|
2009-08-14 16:46:35 +02:00
|
|
|
b = util.table.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end))
|
2009-02-27 17:22:03 +01:00
|
|
|
end
|
|
|
|
|
2009-08-14 16:46:35 +02:00
|
|
|
w:buttons(b)
|
2009-02-27 17:22:03 +01:00
|
|
|
return w
|
|
|
|
end
|
|
|
|
|
2009-05-25 11:14:08 +02:00
|
|
|
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
2009-02-27 17:22:03 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|