2019-11-19 21:00:26 +00:00
|
|
|
#include "labwc.h"
|
2020-08-03 20:56:38 +01:00
|
|
|
#include "theme/theme.h"
|
2020-06-29 19:27:59 +01:00
|
|
|
#include "theme/xbm/xbm.h"
|
2020-08-03 20:56:38 +01:00
|
|
|
#include "common/spawn.h"
|
2019-05-11 21:26:59 +01:00
|
|
|
|
2020-06-03 18:39:46 +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
|
|
|
|
2020-07-16 20:16:43 +01:00
|
|
|
static const char labwc_usage[] =
|
2020-07-20 19:53:03 +01:00
|
|
|
"Usage: labwc [-h] [-s <startup-command>] [-c <config-file>]\n";
|
2020-07-16 20:16:43 +01:00
|
|
|
|
|
|
|
|
static void usage(void)
|
|
|
|
|
{
|
|
|
|
|
printf("%s", labwc_usage);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
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-07-18 11:28:39 +01:00
|
|
|
char *config_file = 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;
|
2020-07-18 11:28:39 +01:00
|
|
|
while ((c = getopt(argc, argv, "s:c:h")) != -1) {
|
2019-05-11 21:26:59 +01:00
|
|
|
switch (c) {
|
|
|
|
|
case 's':
|
|
|
|
|
startup_cmd = optarg;
|
|
|
|
|
break;
|
2020-07-18 11:28:39 +01:00
|
|
|
case 'c':
|
|
|
|
|
config_file = optarg;
|
|
|
|
|
break;
|
2019-05-11 21:26:59 +01:00
|
|
|
default:
|
2020-07-16 20:16:43 +01:00
|
|
|
usage();
|
2019-05-11 21:26:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-16 20:16:43 +01:00
|
|
|
if (optind < argc)
|
|
|
|
|
usage();
|
2019-05-11 21:26:59 +01:00
|
|
|
|
2020-07-18 11:28:39 +01:00
|
|
|
rcxml_read(config_file);
|
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 */
|
|
|
|
|
|
2020-06-03 18:39:46 +01:00
|
|
|
server_init(&server);
|
|
|
|
|
server_start(&server);
|
2020-05-11 06:59:27 +01:00
|
|
|
|
2020-07-20 19:53:03 +01:00
|
|
|
theme_read(rc.theme_name);
|
2020-06-29 19:27:59 +01:00
|
|
|
xbm_load(server.renderer);
|
|
|
|
|
|
2020-06-19 22:29:54 +01:00
|
|
|
if (startup_cmd)
|
|
|
|
|
spawn_async_no_shell(startup_cmd);
|
2020-07-16 20:16:43 +01:00
|
|
|
|
2019-05-11 21:26:59 +01:00
|
|
|
wl_display_run(server.wl_display);
|
2020-06-03 18:39:46 +01:00
|
|
|
server_finish(&server);
|
2019-05-11 21:26:59 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|