commit 0a8644a9b7597719b29426cbbb97b561e1da9e2f
parent a58bec533621023c7846e2e19be0bbed6a9112a7
Author: Bastien Dejean <nihilhill@gmail.com>
Date: Tue, 15 Jan 2019 21:53:45 +0100
Add an option to specify the chain abortion keysym
Fixes #130.
Diffstat:
5 files changed, 27 insertions(+), 12 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: 03/28/2018
+.\" Date: 01/15/2019
.\" Manual: Sxhkd Manual
-.\" Source: Sxhkd 0.5.9
+.\" Source: Sxhkd 0.5.9-1-ga58bec5
.\" Language: English
.\"
-.TH "SXHKD" "1" "03/28/2018" "Sxhkd 0\&.5\&.9" "Sxhkd Manual"
+.TH "SXHKD" "1" "01/15/2019" "Sxhkd 0\&.5\&.9\-1\-ga58bec5" "Sxhkd Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -73,6 +73,11 @@ Redirect the commands output to the given file\&.
.RS 4
Output status information to the given FIFO\&.
.RE
+.PP
+\fB\-a\fR \fIABORT_KEYSYM\fR
+.RS 4
+Name of the keysym used for aborting chord chains\&.
+.RE
.SH "BEHAVIOR"
.sp
\fBsxhkd\fR is a daemon that listens to keyboard events and execute commands\&.
diff --git a/doc/sxhkd.1.asciidoc b/doc/sxhkd.1.asciidoc
@@ -45,6 +45,9 @@ Options
*-s* _STATUS_FIFO_::
Output status information to the given FIFO.
+*-a* _ABORT_KEYSYM_::
+ Name of the keysym used for aborting chord chains.
+
Behavior
--------
diff --git a/src/sxhkd.c b/src/sxhkd.c
@@ -46,15 +46,16 @@ int main(int argc, char *argv[])
timeout = TIMEOUT;
grabbed = false;
redir_fd = -1;
+ abort_keysym = ESCAPE_KEYSYM;
- while ((opt = getopt(argc, argv, "hvm:t:c:r:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "hvm:t:c:r:s:a:")) != -1) {
switch (opt) {
case 'v':
printf("%s\n", VERSION);
exit(EXIT_SUCCESS);
break;
case 'h':
- printf("sxhkd [-h|-v|-m COUNT|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO] [EXTRA_CONFIG ...]\n");
+ printf("sxhkd [-h|-v|-m COUNT|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO|-a ABORT_KEYSYM] [EXTRA_CONFIG ...]\n");
exit(EXIT_SUCCESS);
break;
case 'm':
@@ -75,6 +76,11 @@ int main(int argc, char *argv[])
case 's':
fifo_path = optarg;
break;
+ case 'a':
+ if (!parse_keysym(optarg, &abort_keysym)) {
+ warn("Invalid keysym name: %s.\n", optarg);
+ }
+ break;
}
}
@@ -110,7 +116,7 @@ int main(int argc, char *argv[])
setup();
get_standard_keysyms();
get_lock_fields();
- escape_chord = make_chord(ESCAPE_KEYSYM, XCB_NONE, 0, XCB_KEY_PRESS, false, false);
+ abort_chord = make_chord(abort_keysym, XCB_NONE, 0, XCB_KEY_PRESS, false, false);
load_config(config_file);
for (int i = 0; i < num_extra_confs; i++)
load_config(extra_confs[i]);
@@ -186,7 +192,7 @@ int main(int argc, char *argv[])
ungrab();
cleanup();
- destroy_chord(escape_chord);
+ destroy_chord(abort_chord);
xcb_key_symbols_free(symbols);
xcb_disconnect(dpy);
return EXIT_SUCCESS;
@@ -236,10 +242,10 @@ void mapping_notify(xcb_generic_event_t *evt)
if (e->request == XCB_MAPPING_POINTER)
return;
if (xcb_refresh_keyboard_mapping(symbols, e) == 1) {
- destroy_chord(escape_chord);
+ destroy_chord(abort_chord);
get_lock_fields();
reload_cmd();
- escape_chord = make_chord(ESCAPE_KEYSYM, XCB_NONE, 0, XCB_KEY_PRESS, false, false);
+ abort_chord = make_chord(abort_keysym, XCB_NONE, 0, XCB_KEY_PRESS, false, false);
if (mapping_count > 0)
mapping_count--;
}
diff --git a/src/sxhkd.h b/src/sxhkd.h
@@ -59,7 +59,8 @@ int timeout;
hotkey_t *hotkeys_head, *hotkeys_tail;
bool running, grabbed, toggle_grab, reload, bell, chained, locked;
-chord_t *escape_chord;
+xcb_keysym_t abort_keysym;
+chord_t *abort_chord;
uint16_t num_lock;
uint16_t caps_lock;
diff --git a/src/types.c b/src/types.c
@@ -92,9 +92,9 @@ hotkey_t *find_hotkey(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfiel
if (num_active > 0) {
chained = true;
put_status(BEGIN_CHAIN_PREFIX, "Begin chain");
- grab_chord(escape_chord);
+ grab_chord(abort_chord);
}
- } else if (num_active == 0 || match_chord(escape_chord, event_type, keysym, button, modfield)) {
+ } else if (num_active == 0 || match_chord(abort_chord, event_type, keysym, button, modfield)) {
abort_chain();
return find_hotkey(keysym, button, modfield, event_type, replay_event);
}