about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-13 12:38:58 +0200
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-13 12:38:58 +0200
commit4e26d5ef5d67777519d0ddd934ac2240a9fc7277 (patch)
tree5e874de56cbe3e496159e4604b90f7c3daed52ac
parentImproved screenshot script (diff)
downloaddmenu-4e26d5ef5d67777519d0ddd934ac2240a9fc7277.tar.gz
dmenu-4e26d5ef5d67777519d0ddd934ac2240a9fc7277.tar.bz2
dmenu-4e26d5ef5d67777519d0ddd934ac2240a9fc7277.zip
Added opacity patch [Patch]
-rw-r--r--config.h6
-rw-r--r--dmenu.115
-rw-r--r--dmenu.c16
-rw-r--r--patches/dmenu-opacity.diff116
4 files changed, 150 insertions, 3 deletions
diff --git a/config.h b/config.h
index 11d6688..f4dfe6a 100644
--- a/config.h
+++ b/config.h
@@ -6,6 +6,10 @@ static int topbar = 1;                      /* -b  option; if 0, dmenu appears a
 static const char *fonts[] = {
 	"Noto Sans Display Nerd Font:size=10"
 };
+
+static char *name = "dmenu";
+static char *class = "Dmenu";
+
 static const char *prompt      = NULL;      /* -p  option; prompt to the left of input field */
 
 static const char col_gray1[]       = "#222222";
@@ -16,6 +20,8 @@ static const char col_cyan[]        = "#005577";
 static const char col_black[]       = "#000000";
 static const char col_aqua[]        = "#00ffff";
 
+static double opacity = 1.0;
+
 static const char *colors[SchemeLast][2] = {
 	/*                  fg          bg    */
 	[SchemeNorm] = { col_gray3,  col_gray1},
diff --git a/dmenu.1 b/dmenu.1
index 84ccf21..9beef75 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -4,6 +4,12 @@ dmenu \- dynamic menu
 .SH SYNOPSIS
 .B dmenu
 .RB [ \-bfivx ]
+.RB [ \-n
+.IR name ]
+.RB [ \-c
+.IR class ]
+.RB [ \-o
+.IR opacity ]
 .RB [ \-l
 .IR lines ]
 .RB [ \-m
@@ -47,6 +53,15 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
 .B \-i
 dmenu matches menu items case insensitively.
 .TP
+.BI \-n " name"
+defines window name for dmenu. Defaults to "dmenu".
+.TP
+.BI \-c " class"
+defines window class for dmenu. Defaults to "Dmenu".
+.TP
+.BI \-o " opacity"
+defines window opacity for dmenu. Defaults to 1.0.
+.TP
 .BI \-l " lines"
 dmenu lists items vertically, with the given number of lines.
 .TP
diff --git a/dmenu.c b/dmenu.c
index 665ade5..0ff31b2 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -50,6 +50,9 @@ static Display *dpy;
 static Window root, parentwin, win;
 static XIC xic;
 
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
+
 static Drw *drw;
 static Clr *scheme[SchemeLast];
 
@@ -793,8 +796,9 @@ setup(void)
 	                    CopyFromParent, CopyFromParent, CopyFromParent,
 	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
 	XSetClassHint(dpy, win, &ch);
-  XChangeProperty(dpy, win, type, XA_ATOM, 32, PropModeReplace,
-  (unsigned char *) &dock, 1);
+  opacity = MIN(MAX(opacity, 0), 1);
+  unsigned int opacity_set = (unsigned int)(opacity * OPAQUE);
+  XChangeProperty(dpy, win, XInternAtom(dpy, OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity_set, 1L);
 
 
 	/* input methods */
@@ -822,7 +826,7 @@ static void
 usage(void)
 {
 	fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
-	      "             [-h height]\n"
+				"             [-n name] [-c class] [ -o opacity] [-h height]\n"
 	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
 	exit(1);
 }
@@ -860,6 +864,12 @@ main(int argc, char *argv[])
       lineheight = atoi(argv[++i]);
       lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */
     }
+    else if (!strcmp(argv[i], "-n")) /* dmenu window name */
+      name = argv[++i];
+    else if (!strcmp(argv[i], "-c")) /* dmenu window class */
+      class = argv[++i];
+    else if (!strcmp(argv[i], "-o"))  /* opacity */
+      opacity = atof(argv[++i]);
 		else if (!strcmp(argv[i], "-nb"))  /* normal background color */
 			colors[SchemeNorm][ColBg] = argv[++i];
 		else if (!strcmp(argv[i], "-nf"))  /* normal foreground color */
diff --git a/patches/dmenu-opacity.diff b/patches/dmenu-opacity.diff
new file mode 100644
index 0000000..c45a1d7
--- /dev/null
+++ b/patches/dmenu-opacity.diff
@@ -0,0 +1,116 @@
+# HG changeset patch
+# User MichaƂ Lemke <lemke.michal@gmail.com>
+# Date 1361752727 -3600
+# Node ID 9c3c66de76d74648b9e4b3e9e7f83d4cdde015f3
+# Parent  23d08e2d73f3087274da96bdcdc03f54076fb76b
+add options to change opacity, window class and window name
+
+diff --git a/README b/README
+--- a/README
++++ b/README
+@@ -1,7 +1,8 @@
+ dmenu - dynamic menu
+ ====================
+ dmenu is an efficient dynamic menu for X.
+-
++This version is fork of origal dmenu patched with XFT, quiet, x & y, token, follow focus, tab nav, filter.
++Also enables options to set screen on which dmenu apperars, as long as opacity, window class and window name.
+ 
+ Requirements
+ ------------
+diff --git a/dmenu.1 b/dmenu.1
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -10,6 +10,12 @@
+ .RB [ \-t ]
+ .RB [ \-s
+ .IR screen ]
++.RB [ \-name
++.IR name ]
++.RB [ \-class
++.IR class ]
++.RB [ \-o
++.IR opacity ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-h
+@@ -66,6 +72,15 @@
+ .BI \-s " screen"
+ dmenu apears on the specified screen number. Number given corespondes to screen number in X configuration.
+ .TP
++.BI \-name " name"
++defines window name for dmenu. Defaults to "dmenu".
++.TP
++.BI \-class " class"
++defines window class for dmenu. Defaults to "Dmenu".
++.TP
++.BI \-o " opacity"
++defines window opacity for dmenu. Defaults to 1.0.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -54,6 +54,8 @@
+ static const char *normfgcolor = NULL;
+ static const char *selbgcolor  = NULL;
+ static const char *selfgcolor  = NULL;
++static char *name = "dmenu";
++static char *class = "Dmenu";
+ static unsigned int lines = 0, line_height = 0;
+ static int xoffset = 0;
+ static int yoffset = 0;
+@@ -75,6 +77,10 @@
+ static Item *prev, *curr, *next, *sel;
+ static Window win;
+ static XIC xic;
++static double opacity = 1.0;
++
++#define OPAQUE 0xffffffff
++#define OPACITY "_NET_WM_WINDOW_OPACITY"
+ 
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+ static char *(*fstrstr)(const char *, const char *) = strstr;
+@@ -120,7 +126,13 @@
+ 		else if(!strcmp(argv[i], "-h"))   /* minimum height of single line */
+ 			line_height = atoi(argv[++i]);
+ 		else if(!strcmp(argv[i], "-s"))   /* screen number for dmenu to appear in */
+-			snum = atoi(argv[++i]);			
++			snum = atoi(argv[++i]);
++		else if (!strcmp(argv[i], "-name")) /* dmenu window name */
++			name = argv[++i];
++		else if (!strcmp(argv[i], "-class")) /* dmenu window class */
++			class = argv[++i];
++		else if (!strcmp(argv[i], "-o"))  /* opacity */
++			opacity = atof(argv[++i]);
+ 		else if(!strcmp(argv[i], "-p"))   /* adds prompt to left of input field */
+ 			prompt = argv[++i];
+ 		else if(!strcmp(argv[i], "-fn"))  /* font or font set */
+@@ -753,6 +765,14 @@
+ 	                    DefaultDepth(dc->dpy, screen), CopyFromParent,
+ 	                    DefaultVisual(dc->dpy, screen),
+ 	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
++  XClassHint hint = { .res_name = name, .res_class = class };
++  XSetClassHint(dc->dpy, win, &hint);
++
++  opacity = MIN(MAX(opacity, 0), 1);
++  unsigned int opacity_set = (unsigned int)(opacity * OPAQUE);
++  XChangeProperty(dc->dpy, win, XInternAtom(dc->dpy, OPACITY, False),
++											XA_CARDINAL, 32, PropModeReplace,
++											(unsigned char *) &opacity_set, 1L);
+ 
+ 	/* open input methods */
+ 	xim = XOpenIM(dc->dpy, NULL, NULL, NULL);
+@@ -766,7 +786,9 @@
+ 
+ void
+ usage(void) {
+-	fputs("usage: dmenu [-b] [-q] [-f] [-r] [-i] [-s screen] [-l lines] [-p prompt] [-fn font]\n"
++	fputs("usage: dmenu [-b] [-q] [-f] [-r] [-i] [-s screen]\n"
++				"             [-name name] [-class class] [ -o opacity]\n"
++				"             [-l lines] [-p prompt] [-fn font]\n"
+ 	      "             [-x xoffset] [-y yoffset] [-h height] [-w width]\n"
+ 	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
+ 	exit(EXIT_FAILURE);