summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--completions/tofi1
-rw-r--r--doc/config5
-rw-r--r--doc/tofi.5.md8
-rw-r--r--doc/tofi.5.scd7
-rw-r--r--src/config.c3
-rw-r--r--src/main.c4
-rw-r--r--src/tofi.h1
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
diff --git a/doc/config b/doc/config
index 530e768..9f15f35 100644
--- a/doc/config
+++ b/doc/config
@@ -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) {
diff --git a/src/main.c b/src/main.c
index 807f57c..c70daea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}
diff --git a/src/tofi.h b/src/tofi.h
index 994ee0f..d558a9b 100644
--- a/src/tofi.h
+++ b/src/tofi.h
@@ -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];
};