Improve main func

This commit is contained in:
Alex Kotov 2021-11-13 21:47:29 +05:00
parent 2a2f92fae7
commit 03e0b756a5
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 20 additions and 5 deletions

25
dwm.c
View File

@ -2607,33 +2607,48 @@ zoom(const Arg *arg)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
if (argc == 2 && !strcmp("-v", argv[1])) if (argc == 2 && !strcmp("-v", argv[1])) {
die("dwm-"VERSION); die("dwm-"VERSION);
else if (argc != 1) }
if (argc != 1) {
die("usage: dwm [-v]"); die("usage: dwm [-v]");
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) }
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) {
fputs("warning: no locale support\n", stderr); fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL))) }
if (!(dpy = XOpenDisplay(NULL))) {
die("dwm: cannot open display"); die("dwm: cannot open display");
}
checkotherwm(); checkotherwm();
if (!status_start()) { if (!status_start()) {
status_stop(); status_stop();
die("dwm: cannot start status service"); die("dwm: cannot start status service");
} }
if (!datetime_start()) { if (!datetime_start()) {
datetime_stop(); datetime_stop();
die("dwm: cannot start datetime service"); die("dwm: cannot start datetime service");
} }
setup(); setup();
#ifdef __OpenBSD__ #ifdef __OpenBSD__
if (pledge("stdio rpath proc exec", NULL) == -1) if (pledge("stdio rpath proc exec", NULL) == -1) {
die("pledge"); die("pledge");
}
#endif /* __OpenBSD__ */ #endif /* __OpenBSD__ */
scan(); scan();
run(); run();
cleanup(); cleanup();
datetime_stop(); datetime_stop();
status_stop(); status_stop();
XCloseDisplay(dpy); XCloseDisplay(dpy);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }