Added all_key to clear all messages by keybinding

This commit is contained in:
Miles Sandlar 2012-07-13 18:44:26 -04:00
parent 4507b704e0
commit fc74d6bf18
2 changed files with 22 additions and 1 deletions

21
dunst.c
View File

@ -67,6 +67,7 @@ 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 */
char *key_string = NULL; char *key_string = NULL;
char *history_key_string = NULL; char *history_key_string = NULL;
char *all_key_string = NULL;
KeySym mask = 0; KeySym mask = 0;
int idle_threshold = 0; int idle_threshold = 0;
int show_age_threshold = -1; int show_age_threshold = -1;
@ -86,6 +87,7 @@ static time_t now;
static int visible = False; static int visible = False;
static KeySym key = NoSymbol; static KeySym key = NoSymbol;
static KeySym history_key = NoSymbol; static KeySym history_key = NoSymbol;
static KeySym all_key = NoSymbol;
static screen_info scr; static screen_info scr;
static dimension_t geometry; static dimension_t geometry;
static XScreenSaverInfo *screensaver_info; static XScreenSaverInfo *screensaver_info;
@ -590,6 +592,9 @@ void handleXEvents(void)
if (XLookupKeysym(&ev.xkey, 0) == history_key) { if (XLookupKeysym(&ev.xkey, 0) == history_key) {
history_pop(); history_pop();
} }
if (XLookupKeysym(&ev.xkey, 0) == all_key) {
move_all_to_history();
}
} }
} }
} }
@ -948,6 +953,12 @@ void setup(void)
XGrabKey(dc->dpy, code, mask, root, True, GrabModeAsync, XGrabKey(dc->dpy, code, mask, root, True, GrabModeAsync,
GrabModeAsync); GrabModeAsync);
} }
if (all_key != NoSymbol) {
code = XKeysymToKeycode(dc->dpy, all_key);
XGrabKey(dc->dpy, code, mask, root, True, GrabModeAsync,
GrabModeAsync);
}
} }
void map_win(void) void map_win(void)
@ -988,6 +999,7 @@ void parse_cmdline(int argc, char *argv[])
{"format", required_argument, NULL, 'f'}, {"format", required_argument, NULL, 'f'},
{"key", required_argument, NULL, 'k'}, {"key", required_argument, NULL, 'k'},
{"history_key", required_argument, NULL, 'K'}, {"history_key", required_argument, NULL, 'K'},
{"all_key", required_argument, NULL, 'A'},
{"geometry", required_argument, NULL, 'g'}, {"geometry", required_argument, NULL, 'g'},
{"config", required_argument, NULL, 'r'}, {"config", required_argument, NULL, 'r'},
{"mod", required_argument, NULL, 'M'}, {"mod", required_argument, NULL, 'M'},
@ -1057,6 +1069,9 @@ void parse_cmdline(int argc, char *argv[])
case 'K': case 'K':
history_key_string = optarg; history_key_string = optarg;
break; break;
case 'A':
all_key_string = optarg;
break;
case 'g': case 'g':
geom = optarg; geom = optarg;
break; break;
@ -1174,6 +1189,8 @@ dunst_ini_handle(void *user_data, const char *section,
key_string = dunst_ini_get_string(value); key_string = dunst_ini_get_string(value);
else if (strcmp(name, "history_key") == 0) else if (strcmp(name, "history_key") == 0)
history_key_string = dunst_ini_get_string(value); history_key_string = dunst_ini_get_string(value);
else if (strcmp(name, "all_key") == 0)
all_key_string = dunst_ini_get_string(value);
else if (strcmp(name, "idle_threshold") == 0) else if (strcmp(name, "idle_threshold") == 0)
idle_threshold = atoi(value); idle_threshold = atoi(value);
else if (strcmp(name, "monitor") == 0) else if (strcmp(name, "monitor") == 0)
@ -1338,6 +1355,8 @@ int main(int argc, char *argv[])
key = key_string ? XStringToKeysym(key_string) : NoSymbol; key = key_string ? XStringToKeysym(key_string) : NoSymbol;
history_key = history_key =
history_key_string ? XStringToKeysym(history_key_string) : NoSymbol; history_key_string ? XStringToKeysym(history_key_string) : NoSymbol;
all_key =
all_key_string ? XStringToKeysym(all_key_string) : NoSymbol;
screensaver_info = XScreenSaverAllocInfo(); screensaver_info = XScreenSaverAllocInfo();
initdbus(); initdbus();
@ -1362,7 +1381,7 @@ int main(int argc, char *argv[])
void usage(int exit_status) void usage(int exit_status)
{ {
fputs fputs
("usage: dunst [-h/--help] [-v] [-geometry geom] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-lto secs] [-cto secs] [-nto secs] [-key key] [-history_key key] [-mod modifier] [-mon n] [-config dunstrc]\n", ("usage: dunst [-h/--help] [-v] [-geometry geom] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-lto secs] [-cto secs] [-nto secs] [-key key] [-history_key key] [-all_key key] [-mod modifier] [-mon n] [-config dunstrc]\n",
stderr); stderr);
exit(exit_status); exit(exit_status);
} }

View File

@ -22,6 +22,8 @@
# use xev to find the names for keys # use xev to find the names for keys
key = space key = space
# key to clear all messages
all_key = Menu
# key to redisplay last message(s) # key to redisplay last message(s)
history_key = grave history_key = grave