aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Potocki <dawid@dawidpotocki.com>2021-02-24 21:24:54 +1300
committerDawid Potocki <dawid@dawidpotocki.com>2021-02-25 10:25:44 +1300
commit0d9e3ffb18f8cb388a707f9b1d9db47005a0dcb1 (patch)
tree3b5218e30f2f835737159c79ceab3446970041d0
parent1a13d0465d1a6f4f74bc5b07b04c9bd542f20ba6 (diff)
Apply few personal changesHEADmaster
Patches: - line height - password
-rw-r--r--.gitignore4
-rw-r--r--README24
-rw-r--r--README.md26
-rw-r--r--config.def.h23
-rw-r--r--config.h34
-rw-r--r--dmenu.19
-rw-r--r--dmenu.c31
7 files changed, 96 insertions, 55 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5c14bc0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.o
+
+dmenu
+stest
diff --git a/README b/README
deleted file mode 100644
index a8fcdfe..0000000
--- a/README
+++ /dev/null
@@ -1,24 +0,0 @@
-dmenu - dynamic menu
-====================
-dmenu is an efficient dynamic menu for X.
-
-
-Requirements
-------------
-In order to build dmenu you need the Xlib header files.
-
-
-Installation
-------------
-Edit config.mk to match your local setup (dmenu is installed into
-the /usr/local namespace by default).
-
-Afterwards enter the following command to build and install dmenu
-(if necessary as root):
-
- make clean install
-
-
-Running dmenu
--------------
-See the man page for details.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d5cb887
--- /dev/null
+++ b/README.md
@@ -0,0 +1,26 @@
+# dmenu
+
+*Personal fork of dmenu (dynamic menu) from suckless.org*
+
+## Installation
+
+Make sure you have dependencies installed before you build dmenu.
+
+### Dependencies
+
+```sh
+$ sudo pacman -S libxinerama libxft # Arch Linux
+```
+
+### Building
+
+```sh
+$ git clone https://git.dawidpotocki.com/dawid/dmenu
+$ cd dmenu
+$ sudo make clean install
+```
+
+## Patches
+
+- [line height](https://tools.suckless.org/dmenu/patches/line-height/)
+- [password](https://tools.suckless.org/dmenu/patches/password/)
diff --git a/config.def.h b/config.def.h
deleted file mode 100644
index 1edb647..0000000
--- a/config.def.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-/* Default settings; can be overriden by command line. */
-
-static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
-/* -fn option overrides fonts[0]; default X11 font or font set */
-static const char *fonts[] = {
- "monospace:size=10"
-};
-static const char *prompt = NULL; /* -p option; prompt to the left of input field */
-static const char *colors[SchemeLast][2] = {
- /* fg bg */
- [SchemeNorm] = { "#bbbbbb", "#222222" },
- [SchemeSel] = { "#eeeeee", "#005577" },
- [SchemeOut] = { "#000000", "#00ffff" },
-};
-/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
-static unsigned int lines = 0;
-
-/*
- * Characters not considered part of a word while deleting words
- * for example: " /?\"&[]"
- */
-static const char worddelimiters[] = " ";
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..be4cd43
--- /dev/null
+++ b/config.h
@@ -0,0 +1,34 @@
+/* See LICENSE file for copyright and license details. */
+/* Default settings; can be overriden by command line. */
+
+static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
+static const char *prompt = NULL; /* -p option; prompt to the left of input field */
+
+/* -fn option overrides fonts[0]; default X11 font or font set */
+static const char *fonts[] = {
+ "monospace:pixelsize=15:antialias=true:hintstyle=hintmedium"
+};
+
+static const char *colors[SchemeLast][2] = {
+ /* foreground background */
+ [SchemeNorm] = { "#966bab", "#15191e" },
+ [SchemeSel] = { "#966bab", "#2c2c38" },
+ [SchemeOut] = { "#966bab", "#15191e" },
+};
+
+/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+static unsigned int lines = 0;
+
+/* -h option; minimum height of a menu line */
+static unsigned int lineheight = 32;
+static unsigned int min_lineheight = 0;
+
+/*
+ * Characters not considered part of a word while deleting words
+ * for example: " /?\"&[]"
+ */
+static const char worddelimiters[] = " ";
+
+
+/* vim: filetype=c
+ */
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..96861f9 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -3,9 +3,11 @@
dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
-.RB [ \-bfiv ]
+.RB [ \-bfivP ]
.RB [ \-l
.IR lines ]
+.RB [ \-h
+.IR height ]
.RB [ \-m
.IR monitor ]
.RB [ \-p
@@ -47,9 +49,14 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
.B \-i
dmenu matches menu items case insensitively.
.TP
+.B \-P
+dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored.
+.TP
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
.TP
+.BI \-h " height"
+dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
.BI \-m " monitor"
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
from 0.
diff --git a/dmenu.c b/dmenu.c
index 65f25ce..a9568ca 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -37,7 +37,7 @@ struct item {
static char text[BUFSIZ] = "";
static char *embed;
static int bh, mw, mh;
-static int inputw = 0, promptw;
+static int inputw = 0, promptw, passwd = 0;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
static struct item *items = NULL;
@@ -131,7 +131,8 @@ drawmenu(void)
{
unsigned int curpos;
struct item *item;
- int x = 0, y = 0, w;
+ int x = 0, y = 0, fh = drw->fonts->h, w;
+ char *censort;
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, mw, mh, 1, 1);
@@ -143,12 +144,17 @@ drawmenu(void)
/* draw input field */
w = (lines > 0 || !matches) ? mw - x : inputw;
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+ if (passwd) {
+ censort = ecalloc(1, sizeof(text));
+ memset(censort, '.', strlen(text));
+ drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
+ free(censort);
+ } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
+ drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
}
if (lines > 0) {
@@ -525,6 +531,11 @@ readstdin(void)
size_t i, imax = 0, size = 0;
unsigned int tmpmax = 0;
+ if (passwd) {
+ inputw = lines = 0;
+ return;
+ }
+
/* read each line from stdin and add it to the item list */
for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
if (i + 1 >= size / sizeof *items)
@@ -609,6 +620,7 @@ setup(void)
/* calculate menu geometry */
bh = drw->fonts->h + 2;
+ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#ifdef XINERAMA
@@ -689,7 +701,7 @@ setup(void)
static void
usage(void)
{
- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ fputs("usage: dmenu [-bfivP] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
exit(1);
}
@@ -712,12 +724,17 @@ main(int argc, char *argv[])
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
- } else if (i + 1 == argc)
+ } else if (!strcmp(argv[i], "-P")) /* hides the input */
+ passwd = 1;
+ else if (i + 1 == argc)
usage();
/* these options take one argument */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]);
- else if (!strcmp(argv[i], "-m"))
+ else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
+ lineheight = atoi(argv[++i]);
+ lineheight = MAX(lineheight, min_lineheight);
+ } else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i];