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.
|
|
|
|
local function new(_, args)
|
|
|
|
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-04-17 18:08:52 +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-04-17 18:08:52 +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
|
|
|
|
|
|
|
|
w:buttons(b)
|
|
|
|
return w
|
|
|
|
end
|
|
|
|
|
|
|
|
setmetatable(_M, { __call = new })
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|