diff options
author | Phil Jones <philj56@gmail.com> | 2022-10-25 00:31:25 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-10-25 00:31:25 +0100 |
commit | 0d779ef6359ff8a66b7c22ca7dee6b6097faa903 (patch) | |
tree | 2e2786106dd5248e53687f01aba0c62e5499baac | |
parent | 68587e2920b52ad75f0badb4d3040b574797ac9e (diff) |
Add --multi-instance option.
-rw-r--r-- | completions/tofi | 1 | ||||
-rw-r--r-- | doc/config | 5 | ||||
-rw-r--r-- | doc/tofi.5.md | 8 | ||||
-rw-r--r-- | doc/tofi.5.scd | 7 | ||||
-rw-r--r-- | src/config.c | 3 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/tofi.h | 1 |
7 files changed, 27 insertions, 2 deletions
diff --git a/completions/tofi b/completions/tofi index 2fdf549..d40e306 100644 --- a/completions/tofi +++ b/completions/tofi @@ -52,6 +52,7 @@ _tofi() --terminal --hint-font --late-keyboard-init + --multi-instance ) case "${prev}" in @@ -169,6 +169,11 @@ # performance on slow systems. late-keyboard-init = false + # If true, allow multiple simultaneous processes. + # If false, create a lock file on startup to prevent multiple instances + # from running simultaneously. + multi-instance = false + # ### Inclusion # diff --git a/doc/tofi.5.md b/doc/tofi.5.md index 87e3b64..fd27dfb 100644 --- a/doc/tofi.5.md +++ b/doc/tofi.5.md @@ -107,6 +107,14 @@ options. > > Default: false +**multi-instance**=*true\|false* + +> If true, allow multiple simultaneous processes. If false, create a +> lock file on startup to prevent multiple instances from running +> simultaneously. +> +> Default: false + # STYLE OPTIONS **font**=*font* diff --git a/doc/tofi.5.scd b/doc/tofi.5.scd index 95f87d9..2a77435 100644 --- a/doc/tofi.5.scd +++ b/doc/tofi.5.scd @@ -98,6 +98,13 @@ options. Default: false +*multi-instance*=_true|false_ + If true, allow multiple simultaneous processes. + If false, create a lock file on startup to prevent multiple instances + from running simultaneously. + + Default: false + # STYLE OPTIONS *font*=_font_ diff --git a/src/config.c b/src/config.c index 1fca428..75f70b6 100644 --- a/src/config.c +++ b/src/config.c @@ -414,7 +414,6 @@ bool parse_option(struct tofi *tofi, const char *filename, size_t lineno, const } else if (strcasecmp(option, "hide-input") == 0) { tofi->window.entry.hide_input = parse_bool(filename, lineno, value, &err); } else if (strcasecmp(option, "hidden-character") == 0) { - /* Unicode handling is ugly. */ uint32_t ch = parse_char(filename, lineno, value, &err); if (!err) { tofi->window.entry.hidden_character_utf8_length = @@ -429,6 +428,8 @@ bool parse_option(struct tofi *tofi, const char *filename, size_t lineno, const snprintf(tofi->default_terminal, N_ELEM(tofi->default_terminal), "%s", value); } else if (strcasecmp(option, "hint-font") == 0) { tofi->window.entry.harfbuzz.disable_hinting = !parse_bool(filename, lineno, value, &err); + } else if (strcasecmp(option, "multi-instance") == 0) { + tofi->multiple_instance = parse_bool(filename, lineno, value, &err); } else if (strcasecmp(option, "late-keyboard-init") == 0) { tofi->late_keyboard_init = parse_bool(filename, lineno, value, &err); } else if (strcasecmp(option, "output") == 0) { @@ -680,6 +680,7 @@ static void usage() " --terminal <command> Terminal to use for command line\n" " programs in drun mode.\n" " --hint-font <true|false> Perform font hinting.\n" +" --multi-instance <true|false> Allow multiple tofi instances at once.\n" " --late-keyboard-init (EXPERIMENTAL) Delay keyboard\n" " initialisation until after the first\n" " draw to screen.\n" @@ -732,6 +733,7 @@ const struct option long_options[] = { {"drun-print-exec", required_argument, NULL, 0}, {"terminal", required_argument, NULL, 0}, {"hint-font", required_argument, NULL, 0}, + {"multi-instance", required_argument, NULL, 0}, {"output", required_argument, NULL, 0}, {"scale", required_argument, NULL, 0}, {"late-keyboard-init", optional_argument, NULL, 'k'}, @@ -906,7 +908,7 @@ int main(int argc, char *argv[]) parse_args(&tofi, argc, argv); - if (lock_check()) { + if (!tofi.multiple_instance && lock_check()) { log_error("Another instance of tofi is already running.\n"); exit(EXIT_FAILURE); } @@ -88,6 +88,7 @@ struct tofi { bool drun_print_exec; bool fuzzy_match; bool require_match; + bool multiple_instance; char target_output_name[MAX_OUTPUT_NAME_LEN]; char default_terminal[MAX_TERMINAL_NAME_LEN]; }; |