Skip to content

Commit 8fc10ea

Browse files
committed
Add manpage and usage help.
1 parent c475100 commit 8fc10ea

File tree

5 files changed

+165
-26
lines changed

5 files changed

+165
-26
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# greetd-mini-wl-greeter
22

3-
An extremely simple raw Wayland greeter for greetd, inspired by
3+
An extremely simple raw Wayland greeter for
4+
[greetd](https://sr.ht/~kennylevinsen/greetd/), inspired by
45
[lightdm-mini-greeter](https://github.com/prikhi/lightdm-mini-greeter).
56

67
![Screenshot](screenshot.png)
78

89
## Usage
910

1011
Follow the same steps as for e.g. gtkgreet in the [greetd
11-
wiki](https://man.sr.ht/~kennylevinsen/greetd/). See the man page for sway
12-
config suggestions.
12+
wiki](https://man.sr.ht/~kennylevinsen/greetd/). See the man page for
13+
configuration options. All colors and sizes can be customised, and a PNG
14+
background image can be displayed scaled and centered.
1315

1416
## Install
1517

doc/greetd-mini-wl-greeter.1.scd

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
greetd-mini-wl-greeter(1)
2+
3+
# NAME
4+
5+
greetd-mini-wl-greeter - An extremely simple raw Wayland greeter for greetd
6+
7+
# SYNOPSIS
8+
9+
*greetd-mini-wl-greeter* -u user -c command [options]
10+
11+
# DESCRIPTION
12+
13+
greetd-mini-wl-greeter is a raw Wayland greeter for greetd, designed for a
14+
single user. It requires a Wayland compositor to run, such as *cage*(1) or
15+
*sway*(1).
16+
17+
# OPTIONS
18+
19+
All options which take a color expect a 3- or 6-digit hex code, e.g. F9A733.
20+
21+
*-u, --user* <username>
22+
The user to login as.
23+
24+
*-c, --command* <command>
25+
The command to run on login.
26+
27+
*-b, --background_image* <image>
28+
An image to use as the background. Currently only PNG images are supported.
29+
30+
*-B, --background_color* <color>
31+
Color of the background in the absence of an image.
32+
33+
*-o, --outline_width* <value>
34+
Width of the outlines around the border, in pixels.
35+
36+
*-O, --outline_color* <color>
37+
Color of the outlines around the border.
38+
39+
*-r, --border_width* <value>
40+
Width of the border in pixels.
41+
42+
*-R, --border_color* <color>
43+
Color of the border.
44+
45+
*-e, --entry_padding* <value>
46+
Padding around the password text in pixels.
47+
48+
*-E, --entry_color* <color>
49+
Color of the password entry box.
50+
51+
*-f, --font_name* <name>
52+
Font to use for the password entry.
53+
54+
*-F, --font_size* <value>
55+
Point size of the password text.
56+
57+
*-C, --password_character* <character>
58+
Character to use to hide the password. Defaults to '·'.
59+
60+
*-n, --width_characters* <value>
61+
Make the password entry box big enough to fit this many characters.
62+
63+
*-w, --wide_layout*
64+
By default, the password entry box will be shrunk vertically to exactly fit
65+
the specified password character. Use this option if you'd rather that it got
66+
laid out like normal text, i.e. the box remains one full character tall.
67+
68+
# EXAMPLES
69+
70+
When using sway as the compositor for greetd-mini-greeter, something like the
71+
following sway config lines produce a nice look:
72+
73+
```
74+
# Remove any window borders
75+
default_border none
76+
hide_edge_borders both
77+
78+
# Add a background image, to avoid a flicker of default background color
79+
output * background /path/to/image fill
80+
81+
# Use the same background image for the greeter
82+
exec greetd-mini-wl-greeter -u username -c command -b /path/to/image
83+
```
84+
85+
Fun can be had with the *-C* option, as it should support any character from
86+
your locale, which is probably a UTF-8 one. For example, the Unicode "Combining
87+
Dot Below" character ( ̣) produces a nice effect.
88+
89+
# AUTHORS
90+
91+
Philip Jones <[email protected]>
92+
93+
# SEE ALSO
94+
95+
*greetd*(1)

meson.build

+18-18
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,21 @@ executable(
7979
install: true
8080
)
8181

82-
# scdoc = find_program('scdoc', required: get_option('man-pages'))
83-
# if scdoc.found()
84-
# sed = find_program('sed')
85-
# sh = find_program('sh')
86-
# mandir = get_option('mandir')
87-
# manpage = 'doc/greetd-mini-greeter.1.scd'
88-
# output = 'greetd-mini-greeter.1'
89-
# custom_target(
90-
# output,
91-
# input: manpage,
92-
# output: output,
93-
# command: [
94-
# sh, '-c', '@0@ < @INPUT@ | sed "s|CSS_PATH|@1@|g;" > @2@'.format(scdoc.path(), css_location, output)
95-
# ],
96-
# install: true,
97-
# install_dir: '@0@/man1'.format(mandir)
98-
# )
99-
# endif
82+
scdoc = find_program('scdoc', required: get_option('man-pages'))
83+
if scdoc.found()
84+
sed = find_program('sed')
85+
sh = find_program('sh')
86+
mandir = get_option('mandir')
87+
manpage = 'doc/greetd-mini-wl-greeter.1.scd'
88+
output = 'greetd-mini-wl-greeter.1'
89+
custom_target(
90+
output,
91+
input: manpage,
92+
output: output,
93+
command: [
94+
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc.path(), output)
95+
],
96+
install: true,
97+
install_dir: '@0@/man1'.format(mandir)
98+
)
99+
endif

meson_options.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('man-pages', type: 'feature', value: 'auto', description: 'Install man pages.')

src/main.c

+46-5
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ static void output_scale(
357357

358358
static void output_done(void *data, struct wl_output *wl_output)
359359
{
360-
//struct client_state *state = data;
361-
/* TODO */
362360
log_debug("Output configuration done.\n");
363361
}
364362

@@ -463,9 +461,37 @@ static const struct wl_surface_listener wl_surface_listener = {
463461
.leave = surface_leave
464462
};
465463

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+
466486
int main(int argc, char *argv[])
467487
{
488+
/*
489+
* Set the locale to the user's default, so we can deal with non-ASCII
490+
* characters.
491+
*/
468492
setlocale(LC_ALL, "");
493+
494+
/* Default options. */
469495
struct client_state state = {
470496
.username = "nobody",
471497
.command = "false",
@@ -493,6 +519,7 @@ int main(int argc, char *argv[])
493519
};
494520

495521

522+
/* Option parsing with getopt. */
496523
struct option long_options[] = {
497524
{"background_image", required_argument, NULL, 'b'},
498525
{"background_color", required_argument, NULL, 'B'},
@@ -507,12 +534,12 @@ int main(int argc, char *argv[])
507534
{"font_size", required_argument, NULL, 'F'},
508535
{"password_character", required_argument, NULL, 'C'},
509536
{"command", required_argument, NULL, 'c'},
510-
{"username", required_argument, NULL, 'u'},
537+
{"user", required_argument, NULL, 'u'},
511538
{"width_characters", required_argument, NULL, 'n'},
512539
{"wide_layout", no_argument, NULL, 'w'},
513540
{NULL, 0, NULL, 0}
514541
};
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";
516543

517544
int opt = getopt_long(argc, argv, short_options, long_options, NULL);
518545
while (opt != -1) {
@@ -581,11 +608,24 @@ int main(int argc, char *argv[])
581608
case 'w':
582609
state.window.entry.tight_layout = false;
583610
break;
611+
case ':':
612+
log_error("Option -%c requires an argument.\n", optopt);
613+
usage();
614+
exit(EXIT_FAILURE);
615+
break;
584616
case '?':
617+
log_error("Unknown option -%c.\n", optopt);
618+
usage();
619+
exit(EXIT_FAILURE);
585620
break;
586621
}
587622
opt = getopt_long(argc, argv, short_options, long_options, NULL);
588623
}
624+
if (optind < argc) {
625+
log_error("Unexpected non-option argument '%s'.\n", argv[optind]);
626+
usage();
627+
exit(EXIT_FAILURE);
628+
}
589629

590630

591631
/*
@@ -753,6 +793,7 @@ int main(int argc, char *argv[])
753793
state.window.surface.redraw = false;
754794
state.window.entry.surface.redraw = false;
755795

796+
/* Create the greetd session. */
756797
create_session(&state);
757798

758799
while (wl_display_dispatch(state.wl_display) != -1) {
@@ -808,7 +849,7 @@ void handle_response(
808849
start_session(state);
809850
break;
810851
case GREETD_REQUEST_START_SESSION:
811-
exit(EXIT_SUCCESS);
852+
state->closed = true;
812853
break;
813854
case GREETD_REQUEST_CANCEL_SESSION:
814855
break;

0 commit comments

Comments
 (0)