Skip to content

Instantly share code, notes, and snippets.

@yvon
Created December 15, 2011 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yvon/1480820 to your computer and use it in GitHub Desktop.
Save yvon/1480820 to your computer and use it in GitHub Desktop.
Awesome (window manager) configuration opening terminal in focused client working directory
awful.key({ modkey, }, "Return",
function ()
pid = client.focus.pid
cpid = string.gsub(awful.util.pread('pgrep -P ' .. pid), "[\r\n]+$", "")
cwd = string.gsub(awful.util.pread('readlink /proc/' .. cpid .. '/cwd'), "[\r\n]+$", "")
if string.len(cwd) > 0 then
awful.util.spawn(terminal .. ' -cd ' .. cwd)
else
awful.util.spawn(terminal)
end
end)
@quapka
Copy link

quapka commented Apr 29, 2018

I was trying to hack together something similar but did not have much of a success. Your solution looks neat, but (un)fortunately awful.util.pread was deprecated, since it is a blocking call.

Have you got a working version without the usage of awful.util.pread? The asynchronous function, like awful.spawn.easy_async make it bit weird to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment