summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2025-07-24 20:49:44 -0500
committerzachir <zachir@librem.one>2025-07-24 20:49:44 -0500
commitf8368dbd3cb0ae8581f0be3f26a157aaab3eb701 (patch)
tree8543de83700c0202549ea28bc2eedd1135c09376 /src
parent66a0ac7f32034e01f93927585c4aecbcde7aa5f4 (diff)
Allow long args in dmenu mode
Diffstat (limited to 'src')
-rw-r--r--src/main.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/main.c b/src/main.c
index 2a37c1c..cc34e2a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -841,7 +841,6 @@ static void dmenu_usage(bool err)
" -P Hide the input text.\n"
" -p Prompt text.\n"
" -m Name of output to display window on.\n"
-" Location on screen to anchor window.\n"
"\n"
"All options listed in \"man 5 tofi\" are also accpted in the form \"--key=value\".\n"
);
@@ -1024,30 +1023,29 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[])
/* Second pass, parse everything else. */
optind = 1;
- if (dmenu_mode)
+ if (dmenu_mode)
opt = getopt_long(argc, argv, dmenu_short_options, long_options, &option_index);
- else
+ else
opt = getopt_long(argc, argv, short_options, long_options, &option_index);
while (opt != -1) {
- if (!dmenu_mode) {
- if (opt == 0) {
+ if (opt == 0) {
+ if (!config_apply(tofi, long_options[option_index].name, optarg)) {
+ exit(EXIT_FAILURE);
+ }
+ } else if (opt == 'k') {
+ /*
+ * Backwards compatibility for --late-keyboard-init not
+ * taking an argument.
+ */
+ if (optarg) {
if (!config_apply(tofi, long_options[option_index].name, optarg)) {
exit(EXIT_FAILURE);
}
- } else if (opt == 'k') {
- /*
- * Backwards compatibility for --late-keyboard-init not
- * taking an argument.
- */
- if (optarg) {
- if (!config_apply(tofi, long_options[option_index].name, optarg)) {
- exit(EXIT_FAILURE);
- }
- } else {
- tofi->late_keyboard_init = true;
- }
+ } else {
+ tofi->late_keyboard_init = true;
}
- } else {
+ }
+ if (dmenu_mode) {
if (opt == 'b') {
if (!config_apply(tofi, "anchor", "bottom")) {
exit(EXIT_FAILURE);
@@ -1069,11 +1067,10 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[])
exit(EXIT_FAILURE);
}
}
- }
- if (dmenu_mode)
opt = getopt_long(argc, argv, dmenu_short_options, long_options, &option_index);
- else
+ } else {
opt = getopt_long(argc, argv, short_options, long_options, &option_index);
+ }
}
if (optind < argc) {