Skip to content

Commit

Permalink
awful.prompt.run: handle command return value from hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 8, 2015
1 parent b3c7efd commit ba0d8e3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/awful/prompt.lua
Expand Up @@ -228,6 +228,9 @@ end
-- @tparam[opt] table args.hooks The "hooks" argument uses a syntax similar to
-- `awful.key`. It will call a function for the matching modifiers + key.
-- It receives the command (widget text/input) as an argument.
-- If the callback returns a command, this will be passed to the
-- `exe_callback`, otherwise nothing gets executed by default, and the hook
-- needs to handle it.
-- hooks = {
-- -- Apply startup notification properties with Shift-Return.
-- {{"Shift" }, "Return", function(command)
Expand All @@ -238,10 +241,8 @@ end
-- -- with ":" in a terminal.
-- {{}, "Return", function(command)
-- if command:sub(1,1) == ":" then
-- command = terminal .. ' -e ' .. command:sub(2)
-- return terminal .. ' -e ' .. command:sub(2)
-- end
-- mypromptbox[awful.screen.focused()]:spawn_and_handle_error(
-- command)
-- end}
-- }
-- @param textbox The textbox to use for the prompt.
Expand Down Expand Up @@ -365,7 +366,16 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
match = match and mod[v2]
end
if match or #modifiers == 0 then
exec(v[3])
local cb
local ret = v[3](command)
if ret then
command = ret
cb = exe_callback
else
-- No callback.
cb = function() end
end
exec(cb)
return
end
end
Expand Down

0 comments on commit ba0d8e3

Please sign in to comment.