diff --git a/config.def.h b/config.def.h index 1412417..ff43265 100644 --- a/config.def.h +++ b/config.def.h @@ -11,6 +11,7 @@ char *format = "%s %b"; /* default format */ int timeouts[] = { 10, 10, 0 }; /* low, normal, critical */ +unsigned int transparency = 1; /* transparency */ char *geom = "0x0"; /* geometry */ int sort = True; /* sort messages by urgency */ int indicate_hidden = True; /* show count of hidden messages */ diff --git a/draw.c b/draw.c index d55db09..66ea483 100644 --- a/draw.c +++ b/draw.c @@ -36,6 +36,9 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include +#include + #include "draw.h" #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -231,6 +234,14 @@ void initfont(DC * dc, const char *fontstr) return; } +void +setopacity(DC *dc, Window win, unsigned long opacity) +{ + Atom _NET_WM_WINDOW_OPACITY = XInternAtom(dc->dpy, "_NET_WM_WINDOW_OPACITY", False); + XChangeProperty(dc->dpy, win, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&opacity, 1L); +} + void mapdc(DC * dc, Window win, unsigned int w, unsigned int h) { XCopyArea(dc->dpy, dc->canvas, win, dc->gc, 0, 0, w, h, 0, 0); diff --git a/draw.h b/draw.h index 84f1cfe..645f86c 100644 --- a/draw.h +++ b/draw.h @@ -70,6 +70,7 @@ unsigned long getcolor(DC * dc, const char *colstr); ColorSet *initcolor(DC * dc, const char *foreground, const char *background); DC *initdc(void); void initfont(DC * dc, const char *fontstr); +void setopacity(DC *dc, Window win, unsigned long opacity); void mapdc(DC * dc, Window win, unsigned int w, unsigned int h); void resizedc(DC * dc, unsigned int w, unsigned int h); int textnw(DC * dc, const char *text, size_t len); diff --git a/dunst.c b/dunst.c index 2e17b5b..9632b8c 100644 --- a/dunst.c +++ b/dunst.c @@ -1270,7 +1270,7 @@ void setup(void) CopyFromParent, DefaultVisual(dc->dpy, DefaultScreen(dc->dpy)), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - + setopacity(dc, win, (unsigned long)(transparency * (0xffffffff/100))); grab_key(&history_ks); } @@ -1565,6 +1565,8 @@ dunst_ini_handle(void *user_data, const char *section, sticky_history = dunst_ini_get_boolean(value); else if (strcmp(name, "separator_height") == 0) separator_height = atoi(value); + else if (strcmp(name, "transparency") == 0) + transparency = (100 - atoi(value)); if (strcmp(name, "separator_color") == 0) { char *str = dunst_ini_get_string(value); if (strcmp(str, "auto") == 0) diff --git a/dunstrc b/dunstrc index db3bf4a..af86f06 100644 --- a/dunstrc +++ b/dunstrc @@ -38,6 +38,9 @@ # right side of the screen. Y is measured from the top and down respectevly. geometry = "0x3-30+20" + # the transparency of the window. range: [0; 100] + transparency = 25 + # Don't remove messages, if the user is idle (no mouse or keyboard input) # for longer than idle_threshold seconds. # Set to 0 to disable.