Open blueyed opened 8 years ago
ugly but working for me:
awesome-client 'require("awful").spawn.with_shell("unknown_term || xterm || urxvt")'
(can't wait for a https://github.com/awesomeWM/awesome/issues/1166 :) )
Where is unknown_term
coming from?
it's an example of terminal command which should fail, like unknown_term
is not installed, but xterm
is
UPD however that approach will cause weird behavior if terminal will exit with non-zero
or we could try to do it cleaner but still weird, like:
awful.newmodule.terminals = {'x-terminal-emulator', 'xterm', 'urxvt', 'st', 'whatever else'}
local found_terminal
function awful.newmodule.get_terminal(callback)
if found_terminal then
return callback(found_terminal)
end
local terminal_index = 1
local function _check_next()
local terminal = awful.newmodule.terminals[terminal_index]
awful.spawn.easy_async('which ' .. terminal, function(_, _, _, exit_code)
if exit_code == 0 then
found_terminal = terminal
callback(found_terminal)
else
terminal_index = terminal_index + 1
if terminal_index <= #awful.newmodule.terminals then
_check_next()
else
-- what to do if nothing found? :)
end
end
end)
end
_check_next()
end
function awful.newmodule.set_terminal(terminal)
found_terminal = terminal
end
<...>
awful.newmodule.set_terminal('urxvt')
<...>
awful.key({ modkey, }, "Return", function ()
awful.newmodule.get_terminal(function(term) awful.spawn(term) end)
end,
{description = "open a terminal", group = "launcher"}),
Yeah, I see - but in this example xterm would still be preferred. We should not over-engineer it, but just try to look at what distributions provide.
ah, i've got the point
then we could allow it to override it somehow, see updated example
btw, do we still have some synchronous spawn? it would be easier to use get_terminal()
as synchronous function which returns terminal
In Debian (and ubuntu?), we can simply call x-terminal-emulator -e /some/command
, unfortunately not all distros includes x-terminal-emulator
...
P.S
it would be nice to have a new menu item which opens API documentation:
xdg-open http://new.awesomewm.org/apidoc/index.html
regarding the latter point -- i think it would be better to use file:///usr/share/doc/awesome/doc/index.html
instead
file:///usr/share/doc/awesome/doc/index.html instead
Only with docs installed, otherwise we need to go to wiki website. So we need yet another parser. Useless, don't need.
Link in man page should be enough.
built documentation will match the installed awesome version while online documentation will not
btw, do we still have some synchronous spawn? it would be easier to use get_terminal() as synchronous function which returns terminal
Which synchronous functions were available? The only one that I remember is awful.util.pread
and that was just some small wrapper around io.popen
: https://github.com/awesomeWM/awesome/blob/061751dd9d3a3f08e4efa1739adb4f93e73bee98/lib/awful/util.lua.in#L93-L107
Edit: And of course, the first if
here doesn't help anyone, so is useless. The next if f
is always true, because io.popen
can in practice only fail due to out-of-memory.
yup, that was the one i kept in mind
what do you think of using it for cached sycnhronous get_terminal() function? (see asynchronous example in one of my comments above: https://github.com/awesomeWM/awesome/issues/1217#issuecomment-259575577)
I would think that it would not help you / would not work.
You cannot get the exit code with popen
(you can not even redirect stderr, so all unsuccessful lookups would spam awesome's stderr with something like "sh: sl: command not found").
@Elv13 mb glib have some analogue of which
command?
One annoyance when being dropped into the default config is that you are getting xterm as your terminal.
E.g. with Debian based systems, we could default to
x-terminal-emulator
.I am using urxvt myself, but there seems to be nothing like
x-terminal-emulator
for Arch Linux, or is there?