From cfab8efa406c7ff1063cb6ef89cb41028d0e826e Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Sun, 9 Apr 2023 18:26:52 +0100 Subject: Add --auto-accept-single option. --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index c6e0bdf..a59ac78 100644 --- a/src/main.c +++ b/src/main.c @@ -913,6 +913,7 @@ const struct option long_options[] = { {"history-file", required_argument, NULL, 0}, {"fuzzy-match", required_argument, NULL, 0}, {"require-match", required_argument, NULL, 0}, + {"auto-accept-single", required_argument, NULL, 0}, {"hide-input", required_argument, NULL, 0}, {"hidden-character", required_argument, NULL, 0}, {"drun-launch", required_argument, NULL, 0}, @@ -1198,7 +1199,7 @@ int main(int argc, char *argv[]) } parse_args(&tofi, argc, argv); - log_debug("Config done\n"); + log_debug("Config done.\n"); if (!tofi.multiple_instance && lock_check()) { log_error("Another instance of tofi is already running.\n"); @@ -1498,6 +1499,12 @@ int main(int argc, char *argv[]) } tofi.window.entry.results = string_ref_vec_copy(&tofi.window.entry.commands); + if (tofi.auto_accept_single && tofi.window.entry.results.count == 1) { + log_debug("Only one result, exiting.\n"); + do_submit(&tofi); + return EXIT_SUCCESS; + } + /* * Next, we create the Wayland surface, which takes on the * layer shell role. -- cgit v1.2.3