Add FROM_KIWMIC

This commit is contained in:
buffet 2021-08-09 19:09:48 +00:00
parent 697e5d727a
commit c09e552a69
3 changed files with 20 additions and 0 deletions

View file

@ -27,15 +27,25 @@ ipc_eval(
int top = lua_gettop(L);
lua_pushboolean(L, true);
lua_setglobal(L, "FROM_KIWMIC");
if (luaL_dostring(L, message)) {
const char *error = lua_tostring(L, -1);
wlr_log(WLR_ERROR, "Error running IPC command: %s", error);
kiwmi_command_send_done(
command_resource, KIWMI_COMMAND_ERROR_FAILURE, error);
lua_pop(L, 1);
lua_pushboolean(L, false);
lua_setglobal(L, "FROM_KIWMIC");
return;
}
lua_pushboolean(L, false);
lua_setglobal(L, "FROM_KIWMIC");
int results = top - lua_gettop(L);
if (results == 0) {

View file

@ -224,6 +224,10 @@ luaK_create(struct kiwmi_server *server)
return NULL;
}
// create FROM_KIWMIC global
lua_pushboolean(L, false);
lua_setglobal(L, "FROM_KIWMIC");
// create kiwmi global
lua_pushcfunction(L, luaK_kiwmi_server_new);
lua_pushlightuserdata(L, lua);

View file

@ -6,6 +6,12 @@ This means Lua's garbage collection has no effect on the lifetime of the object.
kiwmi offers the following classes to work with:
## Globals
### `FROM_KIWMIC`
`true` when invoked from kiwmic, `false` otherwise.
## kiwmi_server
This is the type of the global `kiwmi` singleton, representing the compositor.