awful.widget.prompt: import
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c6a63d9250
commit
1cbb1c0666
|
@ -152,7 +152,7 @@ mytasklist.buttons = awful.util.table.join(
|
||||||
|
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
-- Create a promptbox for each screen
|
-- Create a promptbox for each screen
|
||||||
mypromptbox[s] = widget({ type = "textbox", align = "left" })
|
mypromptbox[s] = awful.widget.prompt({ align = "left" })
|
||||||
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
||||||
-- We need one layoutbox per screen.
|
-- We need one layoutbox per screen.
|
||||||
mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
|
mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
|
||||||
|
@ -238,19 +238,12 @@ globalkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
|
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
|
||||||
|
|
||||||
-- Prompt
|
-- Prompt
|
||||||
awful.key({ modkey }, "r",
|
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
|
||||||
function ()
|
|
||||||
awful.prompt.run({ prompt = "Run: " },
|
|
||||||
mypromptbox[mouse.screen],
|
|
||||||
function (...) mypromptbox[mouse.screen].text = awful.util.spawn(unpack(arg)) end,
|
|
||||||
awful.completion.shell,
|
|
||||||
awful.util.getdir("cache") .. "/history")
|
|
||||||
end),
|
|
||||||
|
|
||||||
awful.key({ modkey }, "x",
|
awful.key({ modkey }, "x",
|
||||||
function ()
|
function ()
|
||||||
awful.prompt.run({ prompt = "Run Lua code: " },
|
awful.prompt.run({ prompt = "Run Lua code: " },
|
||||||
mypromptbox[mouse.screen],
|
mypromptbox[mouse.screen].widget,
|
||||||
awful.util.eval, nil,
|
awful.util.eval, nil,
|
||||||
awful.util.getdir("cache") .. "/history_eval")
|
awful.util.getdir("cache") .. "/history_eval")
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -8,6 +8,7 @@ require("awful.widget.taglist")
|
||||||
require("awful.widget.tasklist")
|
require("awful.widget.tasklist")
|
||||||
require("awful.widget.button")
|
require("awful.widget.button")
|
||||||
require("awful.widget.launcher")
|
require("awful.widget.launcher")
|
||||||
|
require("awful.widget.prompt")
|
||||||
|
|
||||||
--- Widget module for awful
|
--- Widget module for awful
|
||||||
module("awful.widget")
|
module("awful.widget")
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
-- @author Julien Danjou <julien@danjou.info>
|
||||||
|
-- @copyright 2009 Julien Danjou
|
||||||
|
-- @release @AWESOME_VERSION@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local unpack = unpack
|
||||||
|
|
||||||
|
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(unpack(arg)) 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(unpack(arg)) end })
|
||||||
|
|
||||||
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
Loading…
Reference in New Issue