From 03e0b756a52dab1603c64921f78450542cffdf01 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 13 Nov 2021 21:47:29 +0500 Subject: [PATCH] Improve main func --- dwm.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/dwm.c b/dwm.c index 6802ca8..7d98c64 100644 --- a/dwm.c +++ b/dwm.c @@ -2607,33 +2607,48 @@ zoom(const Arg *arg) int main(int argc, char *argv[]) { - if (argc == 2 && !strcmp("-v", argv[1])) + if (argc == 2 && !strcmp("-v", argv[1])) { die("dwm-"VERSION); - else if (argc != 1) + } + + if (argc != 1) { die("usage: dwm [-v]"); - if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + } + + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) { fputs("warning: no locale support\n", stderr); - if (!(dpy = XOpenDisplay(NULL))) + } + + if (!(dpy = XOpenDisplay(NULL))) { die("dwm: cannot open display"); + } + checkotherwm(); + if (!status_start()) { status_stop(); die("dwm: cannot start status service"); } + if (!datetime_start()) { datetime_stop(); die("dwm: cannot start datetime service"); } + setup(); + #ifdef __OpenBSD__ - if (pledge("stdio rpath proc exec", NULL) == -1) + if (pledge("stdio rpath proc exec", NULL) == -1) { die("pledge"); + } #endif /* __OpenBSD__ */ + scan(); run(); cleanup(); datetime_stop(); status_stop(); XCloseDisplay(dpy); + return EXIT_SUCCESS; }