commit 804f6ad2688aa55d50bcc5e673f47bad86df4e66 from: Brett Fisher date: Sat May 23 06:43:16 2026 UTC bxnotify.c: Create initial scaffold for development. - Set C headers - Set global variables - Set forward function declarations - Place main() function first - Name utility, setup and teardown, and operational functions commit - fc1da1d1f8ac2cd6eee51391d2b2e25869d13e72 commit + 804f6ad2688aa55d50bcc5e673f47bad86df4e66 blob - 53f3edb79771597dfdb180d0192175e23cdbb224 blob + e538039175d1b279091cc78e378c882c07cefa0f --- bxnotify.c +++ bxnotify.c @@ -1,8 +1,109 @@ /* - * bxnotify.c for bxnotify - * - * A very basic X notification tool, a.k.a Brett's X notify. + * bxnotify + * A very basic X notification tool, a.k.a Brett's X notifier. * See LICENSE.md and README.md for details. */ +/* + * bxnotify.c + * + * A very basic X notification tool, a.k.a. Brett's X notifier. + * See LICENSE.md and README.md for details. + */ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "config.h" + +/* Global Variables */ +static Display *dpy; +static int screen; +static Window win; +static XftFont *font; +static XftDraw *draw; +static XftColor fg, bg, border; +static int running = 1; +static char text[1024]; + +/* Forward Declarations */ +static void die(const char *fmt, ...); +static void cleanup(void); +static void sigusr1(int sig); +static void setup(void); +static void readstdin(void); +static void draw(void); +static void run(void); + +int +main(int argc, char *argv[]) +{ + /* TODO: parse cli flags, override config.h */ + + readstdin(); + setup(); + run(); + cleanup(); + + return 0; +} + +/* implementations */ + +static void +die(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(1); +} + +static void +cleanup(void) +{ + if (draw) XftDrawDestroy(draw); + if (font) XftFontClose(dpy, font); + if (win) XDestroyWindow(dpy, win); + if (dpy) XCloseDisplay(dpy); +} + +static void +sigusr1(int sig) +{ + (void)sig; + running = 0; +} + +static void +setup(void) +{ + /* TODO: open display, create window, allocate colors, font */ +} + +static void +readstdin(void) +{ + /* TODO: read from stdin into text[], handle EOF */ +} + +static void +draw(void) +{ + /* TODO: clear, render text, calculate auto-height */ +} + +static void +run(void) +{ + /* TODO: event loop with timeout, handle Expose and SIGUSR1 */ +} +