From 25cf3d50c41b1a41520fd5acb31e7f2807e41491 Mon Sep 17 00:00:00 2001 From: buffet Date: Mon, 9 Aug 2021 19:09:48 +0000 Subject: [PATCH] Add FROM_KIWMIC --- kiwmi/luak/ipc.c | 10 ++++++++++ kiwmi/luak/luak.c | 4 ++++ lua_docs.md | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/kiwmi/luak/ipc.c b/kiwmi/luak/ipc.c index 6bf6e2d..4e383ec 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 ad40853..bc21e84 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.