commit c057a98ca8cb1333b8d9ba58a20f542689c14299
parent 1d362372b0ef0dfa9060086d6197990273d8cd1b
Author: hhvn <dev@hhvn.uk>
Date: Sat, 12 Jun 2021 18:13:17 +0100
config.h dmenu.c: add shiftswap option/config
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/config.h b/config.h
@@ -4,6 +4,7 @@
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
static int centered = 1; /* -c option; centers dmenu on screen */
static int incremental = 0; /* -r option; incrementally output text */
+static int shiftswap = 0; /* -s option; swap shift+enter and enter */
static int fuzzy = 1;
static int lineheight = 20;
static unsigned int dmw = 600;
diff --git a/dmenu.c b/dmenu.c
@@ -595,7 +595,11 @@ keypress(XKeyEvent *ev)
break;
case XK_Return:
case XK_KP_Enter:
- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
+ if (shiftswap)
+ puts((sel && (ev->state & ShiftMask)) ? sel->text : text);
+ else
+ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
+
if (!(ev->state & ControlMask)) {
cleanup();
exit(0);
@@ -876,6 +880,8 @@ main(int argc, char *argv[])
fast = 1;
else if (!strcmp(argv[i], "-r"))
incremental = 1;
+ else if (!strcmp(argv[i], "-s"))
+ shiftswap = 1;
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
centered = 0;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */