labwc/src/main.c

50 lines
982 B
C
Raw Normal View History

2019-11-19 21:00:26 +00:00
#include "labwc.h"
2020-06-11 21:20:43 +01:00
#include "theme.h"
2020-06-19 22:29:54 +01:00
#include "spawn.h"
2019-05-11 21:26:59 +01:00
struct server server = { 0 };
2020-06-05 23:04:54 +01:00
struct rcxml rc = { 0 };
2020-06-11 21:20:43 +01:00
struct theme theme = { 0 };
2019-12-16 21:19:50 +00:00
2019-12-27 21:22:45 +00:00
int main(int argc, char *argv[])
{
2019-05-11 21:26:59 +01:00
char *startup_cmd = NULL;
2020-05-11 06:59:27 +01:00
wlr_log_init(WLR_ERROR, NULL);
2019-05-11 21:26:59 +01:00
int c;
while ((c = getopt(argc, argv, "s:h")) != -1) {
switch (c) {
case 's':
startup_cmd = optarg;
break;
default:
printf("Usage: %s [-s startup command]\n", argv[0]);
return 0;
}
}
if (optind < argc) {
printf("Usage: %s [-s startup command]\n", argv[0]);
return 0;
}
2020-06-05 23:04:54 +01:00
rcxml_read("data/rc.xml");
2020-06-11 21:20:43 +01:00
theme_read("data/themerc");
2020-06-05 23:04:54 +01:00
2020-05-11 06:59:27 +01:00
/* Wayland requires XDG_RUNTIME_DIR to be set */
if (!getenv("XDG_RUNTIME_DIR")) {
wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is not set");
return 1;
}
/* TODO: Catch signals. Maybe SIGHUP for reconfigure */
server_init(&server);
server_start(&server);
2020-05-11 06:59:27 +01:00
2020-06-19 22:29:54 +01:00
if (startup_cmd)
spawn_async_no_shell(startup_cmd);
2019-05-11 21:26:59 +01:00
wl_display_run(server.wl_display);
server_finish(&server);
2019-05-11 21:26:59 +01:00
return 0;
}