2 * "THE BEER-WARE LICENSE" (Revision 42):
3 * <tobias.rehbein@web.de> wrote this file. As long as you retain this notice
4 * you can do whatever you want with this stuff. If we meet some day, and you
5 * think this stuff is worth it, you can buy me a beer in return.
9 #define _POSIX_C_SOURCE 199506
36 struct clock_context
*clock_ctx
;
37 struct battery_context
*battery_ctx
;
38 struct load_context
*load_ctx
;
39 struct mpd_context
*mpd_ctx
;
42 if (setlocale(LC_ALL
, "") == NULL
)
43 errx(EX_SOFTWARE
, "setlocale()");
45 if ((dpy
= XOpenDisplay(NULL
)) == NULL
)
46 errx(EX_SOFTWARE
, "unable to open display '%s'", XDisplayName(NULL
));
47 screen
= DefaultScreen(dpy
);
48 root
= RootWindow(dpy
, screen
);
51 if ((clock_ctx
= clock_context_open()) == NULL
)
52 errx(EX_SOFTWARE
, "clock_context_open()");
53 if ((battery_ctx
= battery_context_open()) == NULL
)
54 errx(EX_SOFTWARE
, "battery_context_open()");
55 if ((load_ctx
= load_context_open()) == NULL
)
56 errx(EX_SOFTWARE
, "load_context_open()");
57 if ((mpd_ctx
= mpd_context_open()) == NULL
)
58 errx(EX_SOFTWARE
, "mpd_context_open()");
61 char status
[STATUS_BUFFLEN
];
67 if ((clock
= clock_str(clock_ctx
)) == NULL
)
68 err(EX_SOFTWARE
, "clock_str");
69 if ((battery
= battery_str(battery_ctx
)) == NULL
)
70 err(EX_SOFTWARE
, "clock_str");
71 if ((load
= load_str(load_ctx
)) == NULL
)
72 err(EX_SOFTWARE
, "load_str");
73 if ((mpd
= mpd_str(mpd_ctx
)) == NULL
)
74 err(EX_SOFTWARE
, "mpd_str");
76 tools_catitems(status
, sizeof(status
), mpd
, " | ", load
, " | ", battery
, " | ", clock
, NULL
);
77 XStoreName(dpy
, root
, status
);
84 * This code will never be reached (at least at the moment).
85 * Nonetheless I regard it good style to implement cleanup code.
87 mpd_context_close(mpd_ctx
);
88 load_context_close(load_ctx
);
89 battery_context_close(battery_ctx
);
90 clock_context_close(clock_ctx
);