spawn: improve doc, and add `sn` for `awful.util.spawn_with_shell`
Closes https://github.com/awesomeWM/awesome/pull/347.
This commit is contained in:
parent
3fb83ba9b5
commit
f12f9b3b97
|
@ -78,10 +78,12 @@ function util.mkdir(dir)
|
|||
end
|
||||
|
||||
--- Spawn a program.
|
||||
-- @param cmd The command.
|
||||
-- @param sn Enable startup-notification.
|
||||
-- @return The forked PID or an error message
|
||||
-- @return The startup notification UID, if the spawn was successful
|
||||
-- The program gets started on the default screen.
|
||||
-- @tparam string|table cmd The command.
|
||||
-- @tparam boolean sn Enable startup-notification.
|
||||
-- @treturn[1] integer The forked PID.
|
||||
-- @treturn[1] string The startup notification ID, if `sn` is true.
|
||||
-- @treturn[2] string Error message.
|
||||
function util.spawn(cmd, sn)
|
||||
if cmd and cmd ~= "" then
|
||||
if sn == nil then sn = true end
|
||||
|
@ -90,11 +92,16 @@ function util.spawn(cmd, sn)
|
|||
end
|
||||
|
||||
--- Spawn a program using the shell.
|
||||
-- @param cmd The command.
|
||||
function util.spawn_with_shell(cmd)
|
||||
-- @tparam string cmd The command.
|
||||
-- @tparam[opt=false] boolean sn Enable startup-notification?
|
||||
-- @treturn[1] integer The forked PID.
|
||||
-- @treturn[1] string The startup notification ID, if `sn` is true.
|
||||
-- @treturn[2] string Error message.
|
||||
function util.spawn_with_shell(cmd, sn)
|
||||
sn = sn or false
|
||||
if cmd and cmd ~= "" then
|
||||
cmd = { util.shell, "-c", cmd }
|
||||
return capi.awesome.spawn(cmd, false)
|
||||
return util.spawn(cmd, sn)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
8
spawn.c
8
spawn.c
|
@ -338,9 +338,11 @@ parse_command(lua_State *L, int idx, GError **error)
|
|||
/** Spawn a program.
|
||||
* The program will be started on the default screen.
|
||||
*
|
||||
* @param cmd The command to launch.
|
||||
* @param use_sn Use startup-notification, true or false, default to true.
|
||||
* @return Process ID if everything is OK, or an error string if an error occured.
|
||||
* @tparam string|table cmd The command to launch.
|
||||
* @tparam[opt=true] boolean use_sn Use startup-notification?
|
||||
* @treturn[1] integer Process ID if everything is OK.
|
||||
* @treturn[1] string Startup-notification ID, if `use_sn` is true.
|
||||
* @treturn[2] string An error string if an error occured.
|
||||
* @function spawn
|
||||
*/
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue