Set wm class and name with -name

This commit is contained in:
Amadeus Folego 2014-04-30 19:24:02 -03:00
parent 48de907812
commit d2245c70f6
5 changed files with 36 additions and 1 deletions

View File

@ -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.

View File

@ -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 */

View File

@ -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");

View File

@ -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;

16
x.c
View File

@ -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);