diff --git a/kiwmi/luak/ipc.c b/kiwmi/luak/ipc.c index 8809cb4..b47fd8a 100644 --- a/kiwmi/luak/ipc.c +++ b/kiwmi/luak/ipc.c @@ -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) { diff --git a/kiwmi/luak/luak.c b/kiwmi/luak/luak.c index 9a5b75a..6266c90 100644 --- a/kiwmi/luak/luak.c +++ b/kiwmi/luak/luak.c @@ -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); diff --git a/lua_docs.md b/lua_docs.md index e36ca46..7dc7930 100644 --- a/lua_docs.md +++ b/lua_docs.md @@ -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.