diff options
-rw-r--r-- | completions/greetd-mini-wl-greeter | 49 | ||||
-rw-r--r-- | doc/greetd-mini-wl-greeter.1.scd | 26 | ||||
-rw-r--r-- | meson.build | 12 | ||||
-rw-r--r-- | src/main.c | 66 |
4 files changed, 110 insertions, 43 deletions
diff --git a/completions/greetd-mini-wl-greeter b/completions/greetd-mini-wl-greeter new file mode 100644 index 0000000..246e840 --- /dev/null +++ b/completions/greetd-mini-wl-greeter @@ -0,0 +1,49 @@ +# vi: ft=bash + +containsElement () { + local e match="$1" + shift + for e; do [[ "$e" =~ $match ]] && return 0; done + return 1 +} + +_greetd_mini_wl_greeter() +{ + local cur prev opts remaining + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="--background-image --background-color --border-width --border-color --outline-width --outline-color --entry-padding --entry-color --text-color --font-name --font-size --password-character --command --user --width-characters --wide-layout" + + + case "${prev}" in + --user|-u) + COMPREPLY=( $(compgen -W "${users}" -- ${cur}) ) + return 0 + ;; + --command|-c) + return 0 + ;; + --background-image|-b) + if ! containsElement '.*\.png' "${COMP_WORDS[@]}"; then + _filedir '*@(png)' + fi + return 0 + ;; + --?[^w]*) + return 0 + ;; + esac + case "${cur}" in + -[a-zA-Z]) + COMPREPLY=$cur + ;; + *) + remaining=$(echo ${opts[@]} ${COMP_WORDS[@]} ${COMP_WORDS[@]} | tr ' ' '\n' | sort | uniq -u) + COMPREPLY=( $(compgen -W "${remaining}" -- ${cur}) ) + return 0 + ;; + esac + true +} +complete -F _greetd_mini_wl_greeter greetd-mini-wl-greeter diff --git a/doc/greetd-mini-wl-greeter.1.scd b/doc/greetd-mini-wl-greeter.1.scd index b0718f1..54f1dfd 100644 --- a/doc/greetd-mini-wl-greeter.1.scd +++ b/doc/greetd-mini-wl-greeter.1.scd @@ -24,43 +24,43 @@ All options which take a color expect a 3- or 6-digit hex code, e.g. F9A733. *-c, --command* <command> The command to run on login. -*-b, --background_image* <image> +*-b, --background-image* <image> An image to use as the background. Currently only PNG images are supported. -*-B, --background_color* <color> +*-B, --background-color* <color> Color of the background in the absence of an image. -*-o, --outline_width* <value> +*-o, --outline-width* <value> Width of the outlines around the border, in pixels. -*-O, --outline_color* <color> +*-O, --outline-color* <color> Color of the outlines around the border. -*-r, --border_width* <value> +*-r, --border-width* <value> Width of the border in pixels. -*-R, --border_color* <color> +*-R, --border-color* <color> Color of the border. -*-e, --entry_padding* <value> +*-e, --entry-padding* <value> Padding around the password text in pixels. -*-E, --entry_color* <color> +*-E, --entry-color* <color> Color of the password entry box. -*-f, --font_name* <name> +*-f, --font-name* <name> Font to use for the password entry. -*-F, --font_size* <value> +*-F, --font-size* <value> Point size of the password text. -*-C, --password_character* <character> +*-C, --password-character* <character> Character to use to hide the password. Defaults to 'ยท'. -*-n, --width_characters* <value> +*-n, --width-characters* <value> Make the password entry box big enough to fit this many characters. -*-w, --wide_layout* +*-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. diff --git a/meson.build b/meson.build index beaebf2..7a89d15 100644 --- a/meson.build +++ b/meson.build @@ -31,11 +31,23 @@ shader_location = join_paths( '' ) +completion_location = join_paths( + get_option('prefix'), + get_option('datadir'), + 'bash-completion', + 'completions' +) + install_subdir( 'shaders', install_dir: data_location ) +install_data( + 'completions/greetd-mini-wl-greeter', + install_dir: completion_location +) + add_project_arguments( [ '-pedantic', @@ -467,19 +467,19 @@ static void usage() "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" +" -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" ); } @@ -521,22 +521,22 @@ 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'}, - {"border_width", required_argument, NULL, 'r'}, - {"border_color", required_argument, NULL, 'R'}, - {"outline_width", required_argument, NULL, 'o'}, - {"outline_color", required_argument, NULL, 'O'}, - {"entry_padding", required_argument, NULL, 'e'}, - {"entry_color", required_argument, NULL, 'E'}, - {"text_color", required_argument, NULL, 'T'}, - {"font_name", required_argument, NULL, 'f'}, - {"font_size", required_argument, NULL, 'F'}, - {"password_character", required_argument, NULL, 'C'}, + {"background-image", required_argument, NULL, 'b'}, + {"background-color", required_argument, NULL, 'B'}, + {"border-width", required_argument, NULL, 'r'}, + {"border-color", required_argument, NULL, 'R'}, + {"outline-width", required_argument, NULL, 'o'}, + {"outline-color", required_argument, NULL, 'O'}, + {"entry-padding", required_argument, NULL, 'e'}, + {"entry-color", required_argument, NULL, 'E'}, + {"text-color", required_argument, NULL, 'T'}, + {"font-name", required_argument, NULL, 'f'}, + {"font-size", required_argument, NULL, 'F'}, + {"password-character", required_argument, NULL, 'C'}, {"command", required_argument, NULL, 'c'}, {"user", required_argument, NULL, 'u'}, - {"width_characters", required_argument, NULL, 'n'}, - {"wide_layout", no_argument, NULL, 'w'}, + {"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"; @@ -609,12 +609,16 @@ int main(int argc, char *argv[]) state.window.entry.tight_layout = false; break; case ':': - log_error("Option -%c requires an argument.\n", optopt); + log_error( + "Option %s requires an argument.\n", + argv[optind - 1]); usage(); exit(EXIT_FAILURE); break; case '?': - log_error("Unknown option -%c.\n", optopt); + log_error( + "Unknown option %s.\n", + argv[optind - 1]); usage(); exit(EXIT_FAILURE); break; @@ -622,7 +626,9 @@ int main(int argc, char *argv[]) opt = getopt_long(argc, argv, short_options, long_options, NULL); } if (optind < argc) { - log_error("Unexpected non-option argument '%s'.\n", argv[optind]); + log_error( + "Unexpected non-option argument '%s'.\n", + argv[optind]); usage(); exit(EXIT_FAILURE); } |