summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2021-11-01 11:23:43 +0000
committerPhil Jones <philj56@gmail.com>2021-11-01 11:40:28 +0000
commit8fc10eae44b388bee9e5bfdbc0a59c6c7d69ddd8 (patch)
tree13c9b0b4db1110a1ed39e3c7d4fc8ea5b99faca8
parentc47510041f7909c697bc71e0efbc03e3759ca49a (diff)
Add manpage and usage help.
-rw-r--r--README.md8
-rw-r--r--doc/greetd-mini-wl-greeter.1.scd95
-rw-r--r--meson.build36
-rw-r--r--meson_options.txt1
-rw-r--r--src/main.c51
5 files changed, 165 insertions, 26 deletions
diff --git a/README.md b/README.md
index 0c00515..519b976 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# greetd-mini-wl-greeter
-An extremely simple raw Wayland greeter for greetd, inspired by
+An extremely simple raw Wayland greeter for
+[greetd](https://sr.ht/~kennylevinsen/greetd/), inspired by
[lightdm-mini-greeter](https://github.com/prikhi/lightdm-mini-greeter).
![Screenshot](screenshot.png)
@@ -8,8 +9,9 @@ An extremely simple raw Wayland greeter for greetd, inspired by
## Usage
Follow the same steps as for e.g. gtkgreet in the [greetd
-wiki](https://man.sr.ht/~kennylevinsen/greetd/). See the man page for sway
-config suggestions.
+wiki](https://man.sr.ht/~kennylevinsen/greetd/). See the man page for
+configuration options. All colors and sizes can be customised, and a PNG
+background image can be displayed scaled and centered.
## Install
diff --git a/doc/greetd-mini-wl-greeter.1.scd b/doc/greetd-mini-wl-greeter.1.scd
new file mode 100644
index 0000000..b0718f1
--- /dev/null
+++ b/doc/greetd-mini-wl-greeter.1.scd
@@ -0,0 +1,95 @@
+greetd-mini-wl-greeter(1)
+
+# NAME
+
+greetd-mini-wl-greeter - An extremely simple raw Wayland greeter for greetd
+
+# SYNOPSIS
+
+*greetd-mini-wl-greeter* -u user -c command [options]
+
+# DESCRIPTION
+
+greetd-mini-wl-greeter is a raw Wayland greeter for greetd, designed for a
+single user. It requires a Wayland compositor to run, such as *cage*(1) or
+*sway*(1).
+
+# OPTIONS
+
+All options which take a color expect a 3- or 6-digit hex code, e.g. F9A733.
+
+*-u, --user* <username>
+ The user to login as.
+
+*-c, --command* <command>
+ The command to run on login.
+
+*-b, --background_image* <image>
+ An image to use as the background. Currently only PNG images are supported.
+
+*-B, --background_color* <color>
+ Color of the background in the absence of an image.
+
+*-o, --outline_width* <value>
+ Width of the outlines around the border, in pixels.
+
+*-O, --outline_color* <color>
+ Color of the outlines around the border.
+
+*-r, --border_width* <value>
+ Width of the border in pixels.
+
+*-R, --border_color* <color>
+ Color of the border.
+
+*-e, --entry_padding* <value>
+ Padding around the password text in pixels.
+
+*-E, --entry_color* <color>
+ Color of the password entry box.
+
+*-f, --font_name* <name>
+ Font to use for the password entry.
+
+*-F, --font_size* <value>
+ Point size of the password text.
+
+*-C, --password_character* <character>
+ Character to use to hide the password. Defaults to '·'.
+
+*-n, --width_characters* <value>
+ Make the password entry box big enough to fit this many characters.
+
+*-w, --wide_layout*
+ By default, the password entry box will be shrunk vertically to exactly fit
+ the specified password character. Use this option if you'd rather that it got
+ laid out like normal text, i.e. the box remains one full character tall.
+
+# EXAMPLES
+
+When using sway as the compositor for greetd-mini-greeter, something like the
+following sway config lines produce a nice look:
+
+```
+# Remove any window borders
+default_border none
+hide_edge_borders both
+
+# Add a background image, to avoid a flicker of default background color
+output * background /path/to/image fill
+
+# Use the same background image for the greeter
+exec greetd-mini-wl-greeter -u username -c command -b /path/to/image
+```
+
+Fun can be had with the *-C* option, as it should support any character from
+your locale, which is probably a UTF-8 one. For example, the Unicode "Combining
+Dot Below" character ( ̣) produces a nice effect.
+
+# AUTHORS
+
+Philip Jones <philj56@gmail.com>
+
+# SEE ALSO
+
+*greetd*(1)
diff --git a/meson.build b/meson.build
index 1e31456..beaebf2 100644
--- a/meson.build
+++ b/meson.build
@@ -79,21 +79,21 @@ executable(
install: true
)
-# scdoc = find_program('scdoc', required: get_option('man-pages'))
-# if scdoc.found()
-# sed = find_program('sed')
-# sh = find_program('sh')
-# mandir = get_option('mandir')
-# manpage = 'doc/greetd-mini-greeter.1.scd'
-# output = 'greetd-mini-greeter.1'
-# custom_target(
-# output,
-# input: manpage,
-# output: output,
-# command: [
-# sh, '-c', '@0@ < @INPUT@ | sed "s|CSS_PATH|@1@|g;" > @2@'.format(scdoc.path(), css_location, output)
-# ],
-# install: true,
-# install_dir: '@0@/man1'.format(mandir)
-# )
-# endif
+scdoc = find_program('scdoc', required: get_option('man-pages'))
+if scdoc.found()
+ sed = find_program('sed')
+ sh = find_program('sh')
+ mandir = get_option('mandir')
+ manpage = 'doc/greetd-mini-wl-greeter.1.scd'
+ output = 'greetd-mini-wl-greeter.1'
+ custom_target(
+ output,
+ input: manpage,
+ output: output,
+ command: [
+ sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc.path(), output)
+ ],
+ install: true,
+ install_dir: '@0@/man1'.format(mandir)
+ )
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..5371eaf
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('man-pages', type: 'feature', value: 'auto', description: 'Install man pages.')
diff --git a/src/main.c b/src/main.c
index 49779f2..1b5ca1d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -357,8 +357,6 @@ static void output_scale(
static void output_done(void *data, struct wl_output *wl_output)
{
- //struct client_state *state = data;
- /* TODO */
log_debug("Output configuration done.\n");
}
@@ -463,9 +461,37 @@ static const struct wl_surface_listener wl_surface_listener = {
.leave = surface_leave
};
+static void usage()
+{
+ fprintf(stderr,
+"Usage: greetd-mini-wl-greeter -u username -c command [options]\n"
+" -u, --user=NAME The user to login as.\n"
+" -c, --command=COMMAND The command to run on login.\n"
+" -b, --background_image=PATH An image to use as the background.\n"
+" -B, --background_color=COLOR Color of the background.\n"
+" -o, --outline_width=VALUE Width of the border outlines in pixels.\n"
+" -O, --outline_color=COLOR Color of the border outlines.\n"
+" -r, --border_width=VALUE Width of the border in pixels.\n"
+" -R, --border_color=COLOR Color of the border.\n"
+" -e, --entry_padding=VALUE Padding around the password text in pixels.\n"
+" -E, --entry_color=COLOR Color of the password entry box.\n"
+" -f, --font_name=NAME Font to use for the password entry.\n"
+" -F, --font_size=VALUE Point size of the password text.\n"
+" -C, --password_character=CHAR Character to use to hide the password.\n"
+" -n, --width_characters=VALUE Width of the password entry box in characters.\n"
+" -w, --wide_layout Make the password entry box full height.\n"
+ );
+}
+
int main(int argc, char *argv[])
{
+ /*
+ * Set the locale to the user's default, so we can deal with non-ASCII
+ * characters.
+ */
setlocale(LC_ALL, "");
+
+ /* Default options. */
struct client_state state = {
.username = "nobody",
.command = "false",
@@ -493,6 +519,7 @@ int main(int argc, char *argv[])
};
+ /* Option parsing with getopt. */
struct option long_options[] = {
{"background_image", required_argument, NULL, 'b'},
{"background_color", required_argument, NULL, 'B'},
@@ -507,12 +534,12 @@ int main(int argc, char *argv[])
{"font_size", required_argument, NULL, 'F'},
{"password_character", required_argument, NULL, 'C'},
{"command", required_argument, NULL, 'c'},
- {"username", required_argument, NULL, 'u'},
+ {"user", required_argument, NULL, 'u'},
{"width_characters", required_argument, NULL, 'n'},
{"wide_layout", no_argument, NULL, 'w'},
{NULL, 0, NULL, 0}
};
- const char *short_options = "b:B:c:C:e:E:f:F:r:R:n:o:O:T:u:w";
+ const char *short_options = ":b:B:c:C:e:E:f:F:r:R:n:o:O:T:u:w";
int opt = getopt_long(argc, argv, short_options, long_options, NULL);
while (opt != -1) {
@@ -581,11 +608,24 @@ int main(int argc, char *argv[])
case 'w':
state.window.entry.tight_layout = false;
break;
+ case ':':
+ log_error("Option -%c requires an argument.\n", optopt);
+ usage();
+ exit(EXIT_FAILURE);
+ break;
case '?':
+ log_error("Unknown option -%c.\n", optopt);
+ usage();
+ exit(EXIT_FAILURE);
break;
}
opt = getopt_long(argc, argv, short_options, long_options, NULL);
}
+ if (optind < argc) {
+ log_error("Unexpected non-option argument '%s'.\n", argv[optind]);
+ usage();
+ exit(EXIT_FAILURE);
+ }
/*
@@ -753,6 +793,7 @@ int main(int argc, char *argv[])
state.window.surface.redraw = false;
state.window.entry.surface.redraw = false;
+ /* Create the greetd session. */
create_session(&state);
while (wl_display_dispatch(state.wl_display) != -1) {
@@ -808,7 +849,7 @@ void handle_response(
start_session(state);
break;
case GREETD_REQUEST_START_SESSION:
- exit(EXIT_SUCCESS);
+ state->closed = true;
break;
case GREETD_REQUEST_CANCEL_SESSION:
break;