sxhkd-rc

[fork] simple X hotkey daemon (but for the rc shell)
Log | Files | Refs | README | LICENSE

commit 11a2b468623db51c5009641df1f4b3369e1ea2d9
parent 2e7aa9ed9e9c44faf01093c27895e7c0b5ccd325
Author: Bastien Dejean <nihilhill@gmail.com>
Date:   Sun, 11 Aug 2019 17:27:07 +0200

Handle unreachable keysyms

Fixes #148.

Diffstat:
Mdoc/sxhkd.1 | 8++++----
Mdoc/sxhkd.1.asciidoc | 2+-
Msrc/parse.c | 7+++++--
Msrc/types.c | 5++++-
4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/doc/sxhkd.1 b/doc/sxhkd.1 @@ -2,12 +2,12 @@ .\" Title: sxhkd .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> -.\" Date: 02/13/2019 +.\" Date: 08/11/2019 .\" Manual: Sxhkd Manual -.\" Source: Sxhkd 0.6.0 +.\" Source: Sxhkd 0.6.0-2-g2291ee4 .\" Language: English .\" -.TH "SXHKD" "1" "02/13/2019" "Sxhkd 0\&.6\&.0" "Sxhkd Manual" +.TH "SXHKD" "1" "08/11/2019" "Sxhkd 0\&.6\&.0\-2\-g2291ee4" "Sxhkd Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -150,7 +150,7 @@ MODIFIERS_i := MODIFIER_i1 + MODIFIER_i2 + \&... + MODIFIER_ik .sp The valid modifier names are: \fIsuper\fR, \fIhyper\fR, \fImeta\fR, \fIalt\fR, \fIcontrol\fR, \fIctrl\fR, \fIshift\fR, \fImode_switch\fR, \fIlock\fR, \fImod1\fR, \fImod2\fR, \fImod3\fR, \fImod4\fR, \fImod5\fR and \fIany\fR\&. .sp -The keysym names are given by the output of \fBxev\fR\&. +The keysym names are given by the output of \fBxev \-event keyboard\fR\&. .sp Hotkeys and commands can be spread across multiple lines by ending each partial line with a backslash character\&. .sp diff --git a/doc/sxhkd.1.asciidoc b/doc/sxhkd.1.asciidoc @@ -89,7 +89,7 @@ MODIFIERS_i := MODIFIER_i1 + MODIFIER_i2 + … + MODIFIER_ik The valid modifier names are: _super_, _hyper_, _meta_, _alt_, _control_, _ctrl_, _shift_, _mode_switch_, _lock_, _mod1_, _mod2_, _mod3_, _mod4_, _mod5_ and _any_. -The keysym names are given by the output of *xev*. +The keysym names are given by the output of *xev -event keyboard*. Hotkeys and commands can be spread across multiple lines by ending each partial line with a backslash character. diff --git a/src/parse.c b/src/parse.c @@ -2471,7 +2471,7 @@ void process_hotkey(char *hotkey_string, char *command_string) if (strcmp(hotkey, last_hotkey) == 0) num_same++; } else { - free(chain); + destroy_chain(chain); } if (hk_chunks == NULL && cm_chunks == NULL) @@ -2671,7 +2671,7 @@ bool parse_chain(char *string, chain_t *chain) } char *nm = name + offset; if (!parse_modifier(nm, &modfield) && !parse_keysym(nm, &keysym) && !parse_button(nm, &button)) { - warn("Unknown name: '%s'.\n", nm); + warn("Unknown keysym name: '%s'.\n", nm); return false; } } @@ -2680,6 +2680,9 @@ bool parse_chain(char *string, chain_t *chain) if (button != XCB_NONE) event_type = key_to_button(event_type); chord_t *c = make_chord(keysym, button, modfield, event_type, replay_event, lock_chain); + if (c == NULL) { + return false; + } add_chord(chain, c); if (status_fifo != NULL) { snprintf(c->repr, sizeof(c->repr), "%s", chord); diff --git a/src/types.c b/src/types.c @@ -120,7 +120,7 @@ chord_t *make_chord(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield, chord_t *prev = NULL; chord_t *orig = NULL; xcb_keycode_t *keycodes = keycodes_from_keysym(keysym); - if (keycodes != NULL) + if (keycodes != NULL) { for (xcb_keycode_t *kc = keycodes; *kc != XCB_NO_SYMBOL; kc++) { xcb_keysym_t natural_keysym = xcb_key_symbols_get_keysym(symbols, *kc, 0); for (unsigned char col = 0; col < KEYSYMS_PER_KEYCODE; col++) { @@ -154,6 +154,9 @@ chord_t *make_chord(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield, } } } + } else { + warn("No keycodes found for keysym %u.\n", keysym); + } free(keycodes); chord = orig; } else {