@@ -357,8 +357,6 @@ static void output_scale(
357
357
358
358
static void output_done (void * data , struct wl_output * wl_output )
359
359
{
360
- //struct client_state *state = data;
361
- /* TODO */
362
360
log_debug ("Output configuration done.\n" );
363
361
}
364
362
@@ -463,9 +461,37 @@ static const struct wl_surface_listener wl_surface_listener = {
463
461
.leave = surface_leave
464
462
};
465
463
464
+ static void usage ()
465
+ {
466
+ fprintf (stderr ,
467
+ "Usage: greetd-mini-wl-greeter -u username -c command [options]\n"
468
+ " -u, --user=NAME The user to login as.\n"
469
+ " -c, --command=COMMAND The command to run on login.\n"
470
+ " -b, --background_image=PATH An image to use as the background.\n"
471
+ " -B, --background_color=COLOR Color of the background.\n"
472
+ " -o, --outline_width=VALUE Width of the border outlines in pixels.\n"
473
+ " -O, --outline_color=COLOR Color of the border outlines.\n"
474
+ " -r, --border_width=VALUE Width of the border in pixels.\n"
475
+ " -R, --border_color=COLOR Color of the border.\n"
476
+ " -e, --entry_padding=VALUE Padding around the password text in pixels.\n"
477
+ " -E, --entry_color=COLOR Color of the password entry box.\n"
478
+ " -f, --font_name=NAME Font to use for the password entry.\n"
479
+ " -F, --font_size=VALUE Point size of the password text.\n"
480
+ " -C, --password_character=CHAR Character to use to hide the password.\n"
481
+ " -n, --width_characters=VALUE Width of the password entry box in characters.\n"
482
+ " -w, --wide_layout Make the password entry box full height.\n"
483
+ );
484
+ }
485
+
466
486
int main (int argc , char * argv [])
467
487
{
488
+ /*
489
+ * Set the locale to the user's default, so we can deal with non-ASCII
490
+ * characters.
491
+ */
468
492
setlocale (LC_ALL , "" );
493
+
494
+ /* Default options. */
469
495
struct client_state state = {
470
496
.username = "nobody" ,
471
497
.command = "false" ,
@@ -493,6 +519,7 @@ int main(int argc, char *argv[])
493
519
};
494
520
495
521
522
+ /* Option parsing with getopt. */
496
523
struct option long_options [] = {
497
524
{"background_image" , required_argument , NULL , 'b' },
498
525
{"background_color" , required_argument , NULL , 'B' },
@@ -507,12 +534,12 @@ int main(int argc, char *argv[])
507
534
{"font_size" , required_argument , NULL , 'F' },
508
535
{"password_character" , required_argument , NULL , 'C' },
509
536
{"command" , required_argument , NULL , 'c' },
510
- {"username " , required_argument , NULL , 'u' },
537
+ {"user " , required_argument , NULL , 'u' },
511
538
{"width_characters" , required_argument , NULL , 'n' },
512
539
{"wide_layout" , no_argument , NULL , 'w' },
513
540
{NULL , 0 , NULL , 0 }
514
541
};
515
- const char * short_options = "b:B:c:C:e:E:f:F:r:R:n:o:O:T:u:w" ;
542
+ const char * short_options = ": b:B:c:C:e:E:f:F:r:R:n:o:O:T:u:w" ;
516
543
517
544
int opt = getopt_long (argc , argv , short_options , long_options , NULL );
518
545
while (opt != -1 ) {
@@ -581,11 +608,24 @@ int main(int argc, char *argv[])
581
608
case 'w' :
582
609
state .window .entry .tight_layout = false;
583
610
break ;
611
+ case ':' :
612
+ log_error ("Option -%c requires an argument.\n" , optopt );
613
+ usage ();
614
+ exit (EXIT_FAILURE );
615
+ break ;
584
616
case '?' :
617
+ log_error ("Unknown option -%c.\n" , optopt );
618
+ usage ();
619
+ exit (EXIT_FAILURE );
585
620
break ;
586
621
}
587
622
opt = getopt_long (argc , argv , short_options , long_options , NULL );
588
623
}
624
+ if (optind < argc ) {
625
+ log_error ("Unexpected non-option argument '%s'.\n" , argv [optind ]);
626
+ usage ();
627
+ exit (EXIT_FAILURE );
628
+ }
589
629
590
630
591
631
/*
@@ -753,6 +793,7 @@ int main(int argc, char *argv[])
753
793
state .window .surface .redraw = false;
754
794
state .window .entry .surface .redraw = false;
755
795
796
+ /* Create the greetd session. */
756
797
create_session (& state );
757
798
758
799
while (wl_display_dispatch (state .wl_display ) != -1 ) {
@@ -808,7 +849,7 @@ void handle_response(
808
849
start_session (state );
809
850
break ;
810
851
case GREETD_REQUEST_START_SESSION :
811
- exit ( EXIT_SUCCESS ) ;
852
+ state -> closed = true ;
812
853
break ;
813
854
case GREETD_REQUEST_CANCEL_SESSION :
814
855
break ;
0 commit comments