You are not logged in.
Hi,
i'm trying to figure out how to display a promptbox in a bottom-panel.
Here's my code:
wibobox = {}
for s = 1, screen.count() do
-- Create bottom wibox
wibobox[s] = awful.wibox({position = "bottom", screen = s})
wibobox[s].widgets = {
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
}
wibobox[s].visible = false
wibobox[s].screen = s
endawful.key({modkey}, "F1", function()
wibobox[mouse.screen].visible = not wibobox[mouse.screen].visible
awful.prompt.run({prompt = "Run: "},
mypromptbox[mouse.screen],
awful.util.spawn, awful.completion.shell,
awful.util.getdir("cache") .. "/history")
end)When pressing modkey + F1 the bottom-panel appears. But there's no "visible" promptbox. Typing "firefox" and hitting enter the webbrowser opens up.
Any idea how to let mypromptbox shine?
Last edited by rednammoc (2014-02-10 22:31:18)
Offline
Added missing declaration and initialisation of mypromptbox which was missing in the last post.
wibobox = {}
mypromptbox = {}
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] =awful.widget.prompt({layout = awful.widget.layout.leftright})
-- Create bottom wibox for each screen
wibobox[s] = awful.wibox({position = "bottom", screen = s})
wibobox[s].widgets = {
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
}
wibobox[s].visible = false
wibobox[s].screen = s
endOffline
Seems there's a problem with the awful.prompt.run-Command.
-- Prompt
awful.key({modkey}, "F1", function()
wibobox[mouse.screen].visible = not wibobox[mouse.screen].visible
mypromptbox[mouse.screen]:run({prompt = "Run:"})
end),For now ... less is more.
Offline
... and for those of you who want a complete working solution ...
Description: Adds hidden bottom-wibox with promptbox for each screen which toggles when pressing [mod4]+[F1].
Init: Define wibobox and close-button.
wibobox = {}
mypromptbox = {}
wibotogglebtn = widget({ type = "imagebox" })
wibotogglebtn.image = image(beautiful.titlebar_close_button_normal)
wibotogglebtn:buttons(awful.util.table.join(
awful.button({ }, 1, function () wibotoggle() end) -- left mouse button click
))Helper: Define wibotoggle function to hide/unhide wibobox and loose mypromptbox-focus.
function wibotoggle()
wibobox[mouse.screen].visible = not wibobox[mouse.screen].visible
keygrabber.stop()
endWibo-Setup Add wibobox, promptbox and close-button for each screen
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({
layout = awful.widget.layout.horizontal.leftright,
})
-- Create bottom wibox for each screen
wibobox[s] = awful.wibox({position = "bottom", screen = s})
wibobox[s].widgets = {
{
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
},
wibotogglebtn,
layout = awful.widget.layout.horizontal.rightleft
}
wibobox[s].visible = false
wibobox[s].screen = s
endKey bindings: Toggle wibobx when pressing [F1] and display prompt-box and close-button.
awful.key({modkey}, "F1", function()
wibobox[mouse.screen].visible = not wibobox[mouse.screen].visible
awful.prompt.run({ prompt = "Run:" },
mypromptbox[mouse.screen].widget,
function (...)
local result = awful.util.spawn(...)
if type(result) == "string" then
promptbox.widget.text = result
end
end,
wibotoggle, -- toggle wibo after hitting enter
awful.util.getdir("cache") .. "/history", nil,
wibotoggle -- toggle wibo after hitting escape
)
end),Notes: I solved this issue by checking out the awesome awful source-code (/usr/share/awesome/lib/awful).
Offline