diff options
Diffstat (limited to 'config.lua')
| -rw-r--r-- | config.lua | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -6,40 +6,29 @@ web = web uv = uv local Dmenu = {} -function Dmenu.select(list, callback) +function Dmenu.select(list, opts, callback) local selection = nil local stdin = uv.new_pipe(); local stdout = uv.new_pipe(); - uv.spawn('dmenu', { stdio = { stdin, stdout, nil } }, function(code) - print('exit') + local args = { '-p', opts.prompt or '>' } + uv.spawn('dmenu', { args = args, stdio = { stdin, stdout, nil } }, function(code) uv.close(stdout) - print('exit close out') uv.close(stdin) - print('exit close in') if code == 0 then callback(nil, selection) else callback('Exit with status code: ' .. code, selection) end - print('done exit') end) - uv.read_start(stdout, function(err, data) - print('-> out', err, data) - if err ~= nil then - callback(err, nil) - elseif data then - selection = data - end + uv.read_start(stdout, function(_err, data) + if data then selection = data end end) for _, value in ipairs(list) do - print('input write') uv.write(stdin, value .. '\n') end - print('shit') uv.shutdown(stdin) - print('end') end local function trim(s) @@ -56,21 +45,22 @@ local urls = { -- Open in new tab web.keymap.set('n', 't', function() - Dmenu.select(urls, function(err, result) + Dmenu.select(urls, { prompt = 'Open tab:' }, function(err, result) if err or not result then return end web.tabopen(trim(result)) end) end) -- Open in current tab web.keymap.set('n', 'o', function() - Dmenu.select(urls, function(err, result) + Dmenu.select(urls, { prompt = 'Open:' }, function(err, result) if err or not result then return end web.open(trim(result)) end) end) + -- Run lua code web.keymap.set('n', 'q', function() - Dmenu.select({}, function(err, result) + Dmenu.select({}, { prompt = 'Lua >' }, function(err, result) if err or not result then return end local run, run_err = load(result) if run_err then print(run_err) end |
