-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (63 loc) · 2.01 KB
/
Copy pathmain.cpp
File metadata and controls
85 lines (63 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <getopt.h>
#include <dlfcn.h>
#include "server.hpp"
extern yawc_server *wm_server;
int main(int argc, char **argv){
//setenv("WLR_DRM_NO_ATOMIC", "1", 1);
#ifdef DEBUG
wlr_log_init(WLR_DEBUG, NULL);
#else
wlr_log_init(WLR_INFO, NULL);
#endif
static struct option long_options[] ={
{"help", no_argument, NULL, 'h'},
{"window-manager", required_argument, NULL, 'w'},
{"startup", required_argument, NULL, 's'},
{"config", required_argument, NULL, 'c'},
{0, 0, 0, 0}
};
char *wm_module_location, *startup_command, *custom_config_path;
wm_module_location = startup_command = custom_config_path = nullptr;
int c, option_index;
while((c = getopt_long(argc, argv, "hw:s:c:", long_options, &option_index)) != -1){
switch(c){
case 'w':
wm_module_location = optarg;
break;
case 's':
startup_command = optarg;
break;
case 'c':
custom_config_path = optarg;
break;
default:
case 'h':
std::printf("%s","-w/--window-manager to pass a custom window manager\n-s/--startup to pass a startup command\n-c/--config to pass a custom config\n");
return 0;
}
}
yawc_server server{};
server.wm = {0};
yawc_config cfg;
if(custom_config_path){
cfg.load(custom_config_path);
} else{
char *home = getenv("XDG_CONFIG_HOME");
std::string path = home ? home : "~/.config";
if(!cfg.load(path + "/yawc.toml")){
cfg.load("/etc/yawc/yawc.toml");
}
}
wm_server = &server;
server.config = &cfg;
if(startup_command){
server.config->autostart_cmds.push_back(startup_command);
}
if(wm_module_location){
server.config->wm_path = wm_module_location;
}
if (server.run()) {
wlr_log(WLR_ERROR, "Failed to start the compositor");
}
return 0;
}