summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrafa_99 <raroma09@gmail.com>2022-03-26 02:38:45 +0000
committerrafa_99 <raroma09@gmail.com>2022-03-26 02:38:45 +0000
commit7dceceb175af597fb97893e4a60ef542048a48f1 (patch)
tree01670ee7eb54bf2d50435fb6f3591498689e6676
parent09c441d397d5bf07dd819d7ade91c0428356a1f6 (diff)
Suckless style stuff
-rw-r--r--.gitignore2
-rw-r--r--Makefile11
-rw-r--r--README.md13
-rw-r--r--config.def.h (renamed from config.h)37
-rw-r--r--xmouseless.c7
5 files changed, 33 insertions, 37 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9387af5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+config.h
+xmouseless
diff --git a/Makefile b/Makefile
index f8e8698..413012e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# xmouseless
VERSION = 0.1.1
-CC = /usr/bin/gcc
-CFLAGS = -Wall -g
+CC = cc
+CFLAGS = -Wall
LDFLAGS = -lX11 -lXtst -lpthread
PREFIX = /usr/local
@@ -9,14 +9,17 @@ PREFIX = /usr/local
SRC = xmouseless.c
BIN = xmouseless
-all: $(BIN)
+all: config.h build
-$(BIN): $(SRC) config.h
+build:
$(CC) $(CFLAGS) -o $(BIN) $(SRC) $(LDFLAGS)
clean:
rm -f $(BIN)
+config.h:
+ cp config.def.h config.h
+
install: all
mkdir -p $(PREFIX)/bin
cp -f $(BIN) $(PREFIX)/bin
diff --git a/README.md b/README.md
index 6685c2e..dda7257 100644
--- a/README.md
+++ b/README.md
@@ -28,10 +28,10 @@ available. When pressing an exit key, the program exits.
The usage is quite intuitive and with some practice, you can move the pointer to
a specific location very fast. Basically, you move the pointer by pressing some
-keys (the defaults are i, k, j and l for up, down, left and right)
-and change the speed by pressing modifier keys.
-The keys f, d and s (by default) are used to simulate mouse clicks and grabbing.
-With some other keys, you can scroll up, down, left and right and execute
+keys (the defaults are h, j, k and l for left, down, up and right)
+and change the speed by pressing number keys from 1 through 3.
+The keys u, i and o (by default) are used to simulate mouse clicks and grabbing.
+With some other keys, you can scroll up, down, left and right and execute
previously defined shell commands.
You probably want to define a key binding to start xmouseless.
@@ -39,7 +39,6 @@ You probably want to define a key binding to start xmouseless.
## Configuration
-The configuration is done in config.h, which is a C header file,
+The configuration is done in config.def.h, which is a C header file,
but you don't need any programming knowledge to edit it.
-After you edited the file, you have to run make again.
-
+After you edited the file, you have to run make again.
diff --git a/config.h b/config.def.h
index 7164980..ae47709 100644
--- a/config.h
+++ b/config.def.h
@@ -1,4 +1,3 @@
-
/* the rate at which the mouse moves in Hz
* does not change its speed */
static const unsigned int move_rate = 50;
@@ -9,50 +8,46 @@ static const unsigned int default_speed = 500;
/* changes the speed of the mouse pointer */
static SpeedBinding speed_bindings[] = {
- /* key speed */
- { XK_Super_L, 3000 },
- { XK_Alt_L, 1500 },
- { XK_a, 100 },
- { XK_Control_L, 10 },
+ /* key speed */
+ { XK_3, 3000 },
+ { XK_2, 1500 },
+ { XK_1, 100 },
};
/* moves the mouse pointer
* you can also add any other direction (e.g. diagonals) */
static MoveBinding move_bindings[] = {
/* key x y */
- { XK_j, -1, 0 },
+ { XK_h, -1, 0 },
{ XK_l, 1, 0 },
- { XK_i, 0, -1 },
- { XK_k, 0, 1 },
+ { XK_k, 0, -1 },
+ { XK_j, 0, 1 },
};
/* 1: left
* 2: middle
* 3: right */
static ClickBinding click_bindings[] = {
- /* key button */
+ /* key button */
{ XK_space, 1 },
- { XK_f, 1 },
- { XK_d, 2 },
- { XK_s, 3 },
+ { XK_u, 1 },
+ { XK_o, 2 },
+ { XK_i, 3 },
};
/* scrolls up, down, left and right
* a higher value scrolls faster */
static ScrollBinding scroll_bindings[] = {
/* key x y */
- { XK_n, 0 , 25 },
- { XK_p, 0 , -25 },
- { XK_plus, 0 , 80 },
- { XK_minus, 0 , -80 },
- { XK_h, 25, 0 },
- { XK_g, -25, 0 },
+ { XK_s, 0 , 25 },
+ { XK_w, 0 , -25 },
+ { XK_d, 25, 0 },
+ { XK_a, -25, 0 },
};
/* executes shell commands */
static ShellBinding shell_bindings[] = {
- /* key command */
- { XK_b, "wmctrl -a firefox" },
+ /* key command */
{ XK_0, "xdotool mousemove 0 0" },
};
diff --git a/xmouseless.c b/xmouseless.c
index 75d2aea..12a789e 100644
--- a/xmouseless.c
+++ b/xmouseless.c
@@ -1,6 +1,6 @@
/*
* xmouseless
-*/
+ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -197,7 +197,6 @@ void handle_key(KeyCode keycode, Bool is_press) {
for (i = 0; i < LENGTH(click_bindings); i++) {
if (click_bindings[i].keysym == keysym) {
click(click_bindings[i].button, is_press);
- printf("click: %i %i\n", click_bindings[i].button, is_press);
}
}
@@ -205,7 +204,6 @@ void handle_key(KeyCode keycode, Bool is_press) {
for (i = 0; i < LENGTH(speed_bindings); i++) {
if (speed_bindings[i].keysym == keysym) {
speed = is_press ? speed_bindings[i].speed : default_speed;
- printf("speed: %i\n", speed);
}
}
@@ -231,7 +229,6 @@ void handle_key(KeyCode keycode, Bool is_press) {
/* 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);
@@ -239,7 +236,7 @@ void handle_key(KeyCode keycode, Bool is_press) {
}
}
- /* exit */
+ /* exit */
for (i = 0; i < LENGTH(exit_keys); i++) {
if (exit_keys[i] == keysym) {
close_x(EXIT_SUCCESS);