Added -o option for writing a startup message on stdout

This commit is contained in:
Martin Vaaden 2016-12-02 22:54:59 +01:00
parent 50fe7d2083
commit 5fc5e67e97
2 changed files with 14 additions and 2 deletions

View File

@ -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>. 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 =back
=head1 FORMATTING =head1 FORMATTING

View File

@ -1264,6 +1264,7 @@ main (int argc, char **argv)
xcb_button_press_event_t *press_ev; xcb_button_press_event_t *press_ev;
char input[4096] = {0, }; char input[4096] = {0, };
bool permanent = false; bool permanent = false;
bool startup_notification = false;
int geom_v[4] = { -1, -1, 0, 0 }; int geom_v[4] = { -1, -1, 0, 0 };
int ch, areas; int ch, areas;
char *wm_name; char *wm_name;
@ -1285,7 +1286,7 @@ main (int argc, char **argv)
// Connect to the Xserver and initialize scr // Connect to the Xserver and initialize scr
xconn(); 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) { switch (ch) {
case 'h': case 'h':
printf ("lemonbar version %s\n", VERSION); 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-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-u Set the underline/overline height in pixels\n"
"\t-B Set background color in #AARRGGBB\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); exit (EXIT_SUCCESS);
case 'g': (void)parse_geometry_string(optarg, geom_v); break; case 'g': (void)parse_geometry_string(optarg, geom_v); break;
case 'p': permanent = true; 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 'F': dfgc = fgc = parse_color(optarg, NULL, (rgba_t)0xffffffffU); break;
case 'U': dugc = ugc = parse_color(optarg, NULL, fgc); break; case 'U': dugc = ugc = parse_color(optarg, NULL, fgc); break;
case 'a': areas = strtoul(optarg, NULL, 10); 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 // Do the heavy lifting
init(wm_name); 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 // The string is strdup'd when the command line arguments are parsed
free(wm_name); free(wm_name);
// Get the fd to Xserver // Get the fd to Xserver