Add Lua config without kiwmi lib
This commit is contained in:
parent
71917a46cf
commit
79e6b392cf
6 changed files with 67 additions and 0 deletions
19
include/luak.h
Normal file
19
include/luak.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef KIWMI_LUAK_H
|
||||
#define KIWMI_LUAK_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <lua.h>
|
||||
|
||||
#include "server.h"
|
||||
|
||||
bool luaK_init(struct kiwmi_server *server);
|
||||
|
||||
#endif /* KIWMI_LUAK_H */
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <lua.h>
|
||||
|
||||
#include "desktop/desktop.h"
|
||||
#include "input/input.h"
|
||||
|
||||
|
@ -19,6 +21,7 @@ struct kiwmi_server {
|
|||
struct wlr_backend *backend;
|
||||
const char *socket;
|
||||
char *config_path;
|
||||
lua_State *L;
|
||||
struct kiwmi_desktop desktop;
|
||||
struct kiwmi_input input;
|
||||
};
|
||||
|
|
27
kiwmi/luak.c
Normal file
27
kiwmi/luak.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "luak.h"
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
|
||||
bool
|
||||
luaK_init(struct kiwmi_server *server)
|
||||
{
|
||||
lua_State *L = luaL_newstate();
|
||||
if (!L) {
|
||||
return false;
|
||||
}
|
||||
|
||||
luaL_openlibs(L);
|
||||
|
||||
// TODO: kiwmi library
|
||||
|
||||
server->L = L;
|
||||
return true;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
kiwmi_sources = files(
|
||||
'luak.c',
|
||||
'main.c',
|
||||
'server.c',
|
||||
'desktop/desktop.c',
|
||||
|
@ -9,6 +10,7 @@ kiwmi_sources = files(
|
|||
)
|
||||
|
||||
kiwmi_deps = [
|
||||
lua,
|
||||
wayland_server,
|
||||
wlroots,
|
||||
xkbcommon,
|
||||
|
|
|
@ -12,11 +12,14 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "luak.h"
|
||||
|
||||
bool
|
||||
server_init(struct kiwmi_server *server, char *config_path)
|
||||
{
|
||||
|
@ -73,6 +76,12 @@ server_init(struct kiwmi_server *server, char *config_path)
|
|||
|
||||
server->config_path = config_path;
|
||||
|
||||
if (!luaK_init(server)) {
|
||||
wlr_log(WLR_ERROR, "Failed to initialize Lua");
|
||||
wl_display_destroy(server->wl_display);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,6 +99,12 @@ server_run(struct kiwmi_server *server)
|
|||
|
||||
setenv("WAYLAND_DISPLAY", server->socket, true);
|
||||
|
||||
if (luaL_dofile(server->L, server->config_path)) {
|
||||
wlr_log(WLR_ERROR, "Error running config: %s", lua_tostring(server->L, -1));
|
||||
wl_display_destroy(server->wl_display);
|
||||
return false;
|
||||
}
|
||||
|
||||
wl_display_run(server->wl_display);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -17,6 +17,7 @@ add_project_arguments(
|
|||
)
|
||||
|
||||
git = find_program('git', required: false)
|
||||
lua = dependency('lua')
|
||||
wayland_server = dependency('wayland-server')
|
||||
wlroots = dependency('wlroots')
|
||||
xkbcommon = dependency('xkbcommon')
|
||||
|
|
Loading…
Reference in a new issue