From d2245c70f621fe9bf47e3ea302c1503e5f043ecd Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Wed, 30 Apr 2014 19:24:02 -0300 Subject: [PATCH] Set wm class and name with -name --- README.pod | 11 ++++++++++- config.def.h | 2 ++ settings.c | 6 ++++++ settings.h | 2 ++ x.c | 16 ++++++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/README.pod b/README.pod index 22d87b3..77d2dc5 100644 --- a/README.pod +++ b/README.pod @@ -5,7 +5,8 @@ dunst - A customizable and lightweight notification-daemon =head1 SYNOPSIS dunst [-geometry geom] [-shrink shrink] [-fn font] [-nf/nb/lf/lb/cf/cb color] -[-to/nto/lto/cto secs] [-format fmt] [-key key] [-mod mod] [-mon n] [-v] +[-to/nto/lto/cto secs] [-format fmt] [-key key] [-mod mod] [-mon n] +[-t/title title] [-c/class class] [-v] =head1 DESCRIPTION @@ -84,6 +85,14 @@ a negative from the right side of the screen. Y is measured from the top and down respectevly. see also EXAMPLES show the notification on monitor n. +=item B<-t/-title title> + +Define the title of notification windows spawned by dunst. + +=item B<-t/-class class> + +Define the class of notification windows spawned by dunst. + =item B<-shrink> Shrink window if it's smaller than the width. Will be ignored if width is 0. diff --git a/config.def.h b/config.def.h index e3d00c5..b40417b 100644 --- a/config.def.h +++ b/config.def.h @@ -15,6 +15,8 @@ char *icons[] = { "info", "info", "emblem-important" }; /* low, normal, critical unsigned int transparency = 0; /* transparency */ char *geom = "0x0"; /* geometry */ +char *title = "Dunst"; /* the title of dunst notification windows */ +char *class = "Dunst"; /* the class of dunst notification windows */ int shrink = False; /* shrinking */ int sort = True; /* sort messages by urgency */ int indicate_hidden = True; /* show count of hidden messages */ diff --git a/settings.c b/settings.c index 656aa1f..4eedc1d 100644 --- a/settings.c +++ b/settings.c @@ -119,6 +119,12 @@ void load_settings(char *cmdline_config_path) free(c); } } + settings.title = + option_get_string("global", "title", "-t/-title", title, + "Define the title of windows spawned by dunst."); + settings.class = + option_get_string("global", "class", "-c/-class", class, + "Define the class of windows spawned by dunst."); settings.geom = option_get_string("global", "geometry", "-geom/-geometry", geom, "Geometry for the window"); diff --git a/settings.h b/settings.h index 55d08f4..54fb406 100644 --- a/settings.h +++ b/settings.h @@ -17,6 +17,8 @@ typedef struct _settings { char *icons[3]; unsigned int transparency; char *geom; + char *title; + char *class; int shrink; int sort; int indicate_hidden; diff --git a/x.c b/x.c index 0b40aa4..0ead4c1 100644 --- a/x.c +++ b/x.c @@ -957,6 +957,22 @@ static void x_set_wm(Window win) Atom data[2]; + /* set window title */ + char *title = settings.title != NULL ? settings.title : "Dunst"; + Atom _net_wm_title = + XInternAtom(xctx.dpy, "_NET_WM_NAME", false); + + XStoreName(xctx.dpy, win, title); + XChangeProperty(xctx.dpy, win, _net_wm_title, + XInternAtom(xctx.dpy, "UTF8_STRING", False), 8, + PropModeReplace, (unsigned char *) settings.title, strlen(settings.title)); + + /* set window class */ + char *class = settings.class != NULL ? settings.class : "Dunst"; + XClassHint classhint = { class, "Dunst" }; + + XSetClassHint(xctx.dpy, win, &classhint); + /* set window type */ Atom net_wm_window_type = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE", false);