chore: added patches
ded4a7ed
11 file(s) · +85 −10
| 2 | 2 | /* Default settings; can be overriden by command line. */ |
|
| 3 | 3 | ||
| 4 | 4 | static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ |
|
| 5 | + | static int centered = 1; /* -c option; centers dmenu on screen */ |
|
| 6 | + | static int min_width = 600; /* minimum width when centered */ |
|
| 7 | + | static int max_width = 1000; /* maximum width when centered */ |
|
| 8 | + | static const float menu_height_ratio = 4.0f; /* This is the ratio used in the original calculation */ |
|
| 5 | 9 | /* -fn option overrides fonts[0]; default X11 font or font set */ |
|
| 6 | 10 | static const char *fonts[] = { |
|
| 7 | - | "monospace:size=10" |
|
| 11 | + | "BerkeleyMono Nerd Font:size=16" |
|
| 8 | 12 | }; |
|
| 9 | 13 | static const char *prompt = NULL; /* -p option; prompt to the left of input field */ |
|
| 10 | 14 | static const char *colors[SchemeLast][2] = { |
|
| 11 | 15 | /* fg bg */ |
|
| 12 | - | [SchemeNorm] = { "#bbbbbb", "#222222" }, |
|
| 13 | - | [SchemeSel] = { "#eeeeee", "#005577" }, |
|
| 16 | + | [SchemeNorm] = { "#ffffff", "#121113" }, |
|
| 17 | + | [SchemeSel] = { "#fbcb97", "#121113" }, |
|
| 14 | 18 | [SchemeOut] = { "#000000", "#00ffff" }, |
|
| 15 | 19 | }; |
|
| 16 | 20 | /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ |
|
| 21 | 25 | * for example: " /?\"&[]" |
|
| 22 | 26 | */ |
|
| 23 | 27 | static const char worddelimiters[] = " "; |
|
| 28 | + | ||
| 29 | + | /* Size of the window border */ |
|
| 30 | + | static unsigned int border_width = 1; |
|
| 1 | + | /* See LICENSE file for copyright and license details. */ |
|
| 2 | + | /* Default settings; can be overriden by command line. */ |
|
| 3 | + | ||
| 4 | + | static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ |
|
| 5 | + | static int centered = 1; /* -c option; centers dmenu on screen */ |
|
| 6 | + | static int min_width = 600; /* minimum width when centered */ |
|
| 7 | + | static int max_width = 1000; /* maximum width when centered */ |
|
| 8 | + | static const float menu_height_ratio = 4.0f; /* This is the ratio used in the original calculation */ |
|
| 9 | + | /* -fn option overrides fonts[0]; default X11 font or font set */ |
|
| 10 | + | static const char *fonts[] = { |
|
| 11 | + | "BerkeleyMono Nerd Font:size=16" |
|
| 12 | + | }; |
|
| 13 | + | static const char *prompt = NULL; /* -p option; prompt to the left of input field */ |
|
| 14 | + | static const char *colors[SchemeLast][2] = { |
|
| 15 | + | /* fg bg */ |
|
| 16 | + | [SchemeNorm] = { "#ffffff", "#121113" }, |
|
| 17 | + | [SchemeSel] = { "#fbcb97", "#121113" }, |
|
| 18 | + | [SchemeOut] = { "#000000", "#00ffff" }, |
|
| 19 | + | }; |
|
| 20 | + | /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ |
|
| 21 | + | static unsigned int lines = 0; |
|
| 22 | + | ||
| 23 | + | /* |
|
| 24 | + | * Characters not considered part of a word while deleting words |
|
| 25 | + | * for example: " /?\"&[]" |
|
| 26 | + | */ |
|
| 27 | + | static const char worddelimiters[] = " "; |
|
| 28 | + | ||
| 29 | + | /* Size of the window border */ |
|
| 30 | + | static unsigned int border_width = 1; |
Binary file — no preview.
| 40 | 40 | .B \-b |
|
| 41 | 41 | dmenu appears at the bottom of the screen. |
|
| 42 | 42 | .TP |
|
| 43 | + | .B \-c |
|
| 44 | + | dmenu appears centered on the screen. |
|
| 45 | + | .TP |
|
| 43 | 46 | .B \-f |
|
| 44 | 47 | dmenu grabs the keyboard before reading stdin if not reading from a tty. This |
|
| 45 | 48 | is faster, but will lock up X until stdin reaches end\-of\-file. |
| 95 | 95 | break; |
|
| 96 | 96 | } |
|
| 97 | 97 | ||
| 98 | + | static int |
|
| 99 | + | max_textw(void) |
|
| 100 | + | { |
|
| 101 | + | int len = 0; |
|
| 102 | + | for (struct item *item = items; item && item->text; item++) |
|
| 103 | + | len = MAX(TEXTW(item->text), len); |
|
| 104 | + | return len; |
|
| 105 | + | } |
|
| 106 | + | ||
| 98 | 107 | static void |
|
| 99 | 108 | cleanup(void) |
|
| 100 | 109 | { |
|
| 636 | 645 | bh = drw->fonts->h + 2; |
|
| 637 | 646 | lines = MAX(lines, 0); |
|
| 638 | 647 | mh = (lines + 1) * bh; |
|
| 648 | + | promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; |
|
| 639 | 649 | #ifdef XINERAMA |
|
| 640 | 650 | i = 0; |
|
| 641 | 651 | if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { |
|
| 662 | 672 | if (INTERSECT(x, y, 1, 1, info[i]) != 0) |
|
| 663 | 673 | break; |
|
| 664 | 674 | ||
| 665 | - | x = info[i].x_org; |
|
| 666 | - | y = info[i].y_org + (topbar ? 0 : info[i].height - mh); |
|
| 667 | - | mw = info[i].width; |
|
| 675 | + | if (centered) { |
|
| 676 | + | mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width); |
|
| 677 | + | mw = MIN(mw, max_width); |
|
| 678 | + | x = info[i].x_org + ((info[i].width - mw) / 2); |
|
| 679 | + | y = info[i].y_org + ((info[i].height - mh) / menu_height_ratio); |
|
| 680 | + | } else { |
|
| 681 | + | x = info[i].x_org; |
|
| 682 | + | y = info[i].y_org + (topbar ? 0 : info[i].height - mh); |
|
| 683 | + | mw = info[i].width; |
|
| 684 | + | } |
|
| 685 | + | ||
| 668 | 686 | XFree(info); |
|
| 669 | 687 | } else |
|
| 670 | 688 | #endif |
|
| 672 | 690 | if (!XGetWindowAttributes(dpy, parentwin, &wa)) |
|
| 673 | 691 | die("could not get embedding window attributes: 0x%lx", |
|
| 674 | 692 | parentwin); |
|
| 675 | - | x = 0; |
|
| 676 | - | y = topbar ? 0 : wa.height - mh; |
|
| 677 | - | mw = wa.width; |
|
| 693 | + | ||
| 694 | + | if (centered) { |
|
| 695 | + | mw = MIN(MAX(max_textw() + promptw, min_width), wa.width); |
|
| 696 | + | mw = MIN(mw, max_width); |
|
| 697 | + | x = (wa.width - mw) / 2; |
|
| 698 | + | y = (wa.height - mh) / 2; |
|
| 699 | + | } else { |
|
| 700 | + | x = 0; |
|
| 701 | + | y = topbar ? 0 : wa.height - mh; |
|
| 702 | + | mw = wa.width; |
|
| 703 | + | } |
|
| 678 | 704 | } |
|
| 679 | 705 | promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; |
|
| 680 | 706 | inputw = mw / 3; /* input width: ~33% of monitor width */ |
|
| 684 | 710 | swa.override_redirect = True; |
|
| 685 | 711 | swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; |
|
| 686 | 712 | swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; |
|
| 687 | - | win = XCreateWindow(dpy, root, x, y, mw, mh, 0, |
|
| 713 | + | win = XCreateWindow(dpy, root, x, y, mw, mh, border_width, |
|
| 688 | 714 | CopyFromParent, CopyFromParent, CopyFromParent, |
|
| 689 | 715 | CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); |
|
| 716 | + | if (border_width) |
|
| 717 | + | XSetWindowBorder(dpy, win, scheme[SchemeSel][ColFg].pixel); |
|
| 690 | 718 | XSetClassHint(dpy, win, &ch); |
|
| 691 | 719 | ||
| 692 | 720 | /* input methods */ |
|
| 733 | 761 | topbar = 0; |
|
| 734 | 762 | else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ |
|
| 735 | 763 | fast = 1; |
|
| 764 | + | else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ |
|
| 765 | + | centered = 1; |
|
| 736 | 766 | else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ |
|
| 737 | 767 | fstrncmp = strncasecmp; |
|
| 738 | 768 | fstrstr = cistrstr; |
|
| 757 | 787 | colors[SchemeSel][ColFg] = argv[++i]; |
|
| 758 | 788 | else if (!strcmp(argv[i], "-w")) /* embedding window id */ |
|
| 759 | 789 | embed = argv[++i]; |
|
| 790 | + | else if (!strcmp(argv[i], "-bw")) |
|
| 791 | + | border_width = atoi(argv[++i]); /* border width */ |
|
| 760 | 792 | else |
|
| 761 | 793 | usage(); |
|
| 762 | 794 | ||
Binary file — no preview.
Binary file — no preview.
| 1 | + | #!/bin/bash |
|
| 2 | + | ||
| 3 | + | ls | dmenu -c -l 20 | xargs nvim |
Binary file — no preview.
Binary file — no preview.
Binary file — no preview.