From 5fc5e67e976d40cf020ebb1f6dcf05537bc2a912 Mon Sep 17 00:00:00 2001 From: Martin Vaaden Date: Fri, 2 Dec 2016 22:54:59 +0100 Subject: [PATCH] Added -o option for writing a startup message on stdout --- README.pod | 4 ++++ lemonbar.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.pod b/README.pod index b4ffccd..2f30b50 100644 --- a/README.pod +++ b/README.pod @@ -65,6 +65,10 @@ Set the foreground color of the bar. Accepts the same color formats as B<-B>. Set the underline color of the bar. Accepts the same color formats as B<-B>. +=item B<-o> + +Print a message ("started\n") to sdtout when the bar has been initialized. + =back =head1 FORMATTING diff --git a/lemonbar.c b/lemonbar.c index 43aab8c..dd48827 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -1264,6 +1264,7 @@ main (int argc, char **argv) xcb_button_press_event_t *press_ev; char input[4096] = {0, }; bool permanent = false; + bool startup_notification = false; int geom_v[4] = { -1, -1, 0, 0 }; int ch, areas; char *wm_name; @@ -1285,7 +1286,7 @@ main (int argc, char **argv) // Connect to the Xserver and initialize scr xconn(); - while ((ch = getopt(argc, argv, "hg:bdf:a:pu:B:F:U:n:")) != -1) { + while ((ch = getopt(argc, argv, "hg:bdf:a:pu:B:F:U:n:o")) != -1) { switch (ch) { case 'h': printf ("lemonbar version %s\n", VERSION); @@ -1300,7 +1301,8 @@ main (int argc, char **argv) "\t-n Set the WM_NAME atom to the specified value for this bar\n" "\t-u Set the underline/overline height in pixels\n" "\t-B Set background color in #AARRGGBB\n" - "\t-F Set foreground color in #AARRGGBB\n", argv[0]); + "\t-F Set foreground color in #AARRGGBB\n" + "\t-o Write a message to stdout when started\n", argv[0]); exit (EXIT_SUCCESS); case 'g': (void)parse_geometry_string(optarg, geom_v); break; case 'p': permanent = true; break; @@ -1313,6 +1315,7 @@ main (int argc, char **argv) case 'F': dfgc = fgc = parse_color(optarg, NULL, (rgba_t)0xffffffffU); break; case 'U': dugc = ugc = parse_color(optarg, NULL, fgc); break; case 'a': areas = strtoul(optarg, NULL, 10); break; + case 'o': startup_notification = true; break; } } @@ -1339,6 +1342,11 @@ main (int argc, char **argv) // Do the heavy lifting init(wm_name); + + if(startup_notification){ + (void)write(STDOUT_FILENO, "started\n", 8); + } + // The string is strdup'd when the command line arguments are parsed free(wm_name); // Get the fd to Xserver