43 lines
1.4 KiB
Lua
43 lines
1.4 KiB
Lua
---------------------------------------------------------------------------
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
-- @copyright 2009 Julien Danjou
|
|
-- @release @AWESOME_VERSION@
|
|
---------------------------------------------------------------------------
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
local capi = { widget = widget }
|
|
local completion = require("awful.completion")
|
|
local util = require("awful.util")
|
|
local prompt = require("awful.prompt")
|
|
|
|
module("awful.widget.prompt")
|
|
|
|
--- Run method for promptbox.
|
|
-- @param promptbox The promptbox to run.
|
|
local function run(promptbox)
|
|
return prompt.run({ prompt = promptbox.prompt },
|
|
promptbox.widget,
|
|
function (...) promptbox.widget.text = util.spawn(...) end,
|
|
completion.shell,
|
|
util.getdir("cache") .. "/history")
|
|
end
|
|
|
|
--- Create a prompt widget which will launch a command.
|
|
-- @param args Standard widget table arguments, with prompt to change the
|
|
-- default prompt.
|
|
-- @return A launcher widget.
|
|
function new(args)
|
|
local args = args or {}
|
|
local promptbox = {}
|
|
args.type = "textbox"
|
|
promptbox.widget = capi.widget(args)
|
|
promptbox.run = run
|
|
promptbox.prompt = args.prompt or "Run: "
|
|
return promptbox
|
|
end
|
|
|
|
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|