summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h6
-rw-r--r--xmouseless.c17
2 files changed, 23 insertions, 0 deletions
diff --git a/config.h b/config.h
index a9eabba..75c6222 100644
--- a/config.h
+++ b/config.h
@@ -39,6 +39,12 @@ static ClickBinding click_bindings[] = {
{ XK_minus, 5 },
};
+static ShellBinding shell_bindings[] = {
+ /* key command */
+ { XK_b, "wmctrl -a firefox" },
+ { XK_t, "echo $0 >> ~/test" },
+};
+
/* exits on key release which allows click and exit with one key */
static unsigned int exit_keys[] = {
XK_Escape, XK_q, XK_space
diff --git a/xmouseless.c b/xmouseless.c
index 90dd4b1..e6acd29 100644
--- a/xmouseless.c
+++ b/xmouseless.c
@@ -1,4 +1,5 @@
/*
+ * xmouseless
*/
#include <stdio.h>
#include <stdlib.h>
@@ -30,6 +31,11 @@ typedef struct {
int speed;
} SpeedBindings;
+typedef struct {
+ KeySym keysym;
+ char *command;
+} ShellBinding;
+
/* load configuration */
#include "config.h"
@@ -171,6 +177,17 @@ void handle_keyrelease(XKeyEvent event) {
}
}
+ /* shell bindings */
+ for (i = 0; i < LENGTH(shell_bindings); i++) {
+ if (shell_bindings[i].keysym == keysym) {
+ printf("executing: %s\n", shell_bindings[i].command);
+ if (fork() == 0) {
+ system(shell_bindings[i].command);
+ exit(EXIT_SUCCESS);
+ }
+ }
+ }
+
/* exit */
for (i = 0; i < LENGTH(exit_keys); i++) {
if (exit_keys[i] == keysym) {