Merge pull request #167 from badosu/add-name-setting

Set wm class and name
This commit is contained in:
Sascha Kruse 2014-06-14 15:26:44 +02:00
commit 605eab0d4a
5 changed files with 36 additions and 1 deletions

View File

@ -5,7 +5,8 @@ dunst - A customizable and lightweight notification-daemon
=head1 SYNOPSIS =head1 SYNOPSIS
dunst [-geometry geom] [-shrink shrink] [-fn font] [-nf/nb/lf/lb/cf/cb color] 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 =head1 DESCRIPTION
@ -84,6 +85,14 @@ a negative from the right side of the screen.
Y is measured from the top and down respectevly. Y is measured from the top and down respectevly.
see also EXAMPLES show the notification on monitor n. 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> =item B<-shrink>
Shrink window if it's smaller than the width. Will be ignored if width is 0. Shrink window if it's smaller than the width. Will be ignored if width is 0.

View File

@ -15,6 +15,8 @@ char *icons[] = { "info", "info", "emblem-important" }; /* low, normal, critical
unsigned int transparency = 0; /* transparency */ unsigned int transparency = 0; /* transparency */
char *geom = "0x0"; /* geometry */ 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 shrink = False; /* shrinking */
int sort = True; /* sort messages by urgency */ int sort = True; /* sort messages by urgency */
int indicate_hidden = True; /* show count of hidden messages */ int indicate_hidden = True; /* show count of hidden messages */

View File

@ -119,6 +119,12 @@ void load_settings(char *cmdline_config_path)
free(c); 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 = settings.geom =
option_get_string("global", "geometry", "-geom/-geometry", geom, option_get_string("global", "geometry", "-geom/-geometry", geom,
"Geometry for the window"); "Geometry for the window");

View File

@ -17,6 +17,8 @@ typedef struct _settings {
char *icons[3]; char *icons[3];
unsigned int transparency; unsigned int transparency;
char *geom; char *geom;
char *title;
char *class;
int shrink; int shrink;
int sort; int sort;
int indicate_hidden; int indicate_hidden;

16
x.c
View File

@ -957,6 +957,22 @@ static void x_set_wm(Window win)
Atom data[2]; 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 */ /* set window type */
Atom net_wm_window_type = Atom net_wm_window_type =
XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE", false); XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE", false);