Skip to content

Commit

Permalink
clean up for public push
Browse files Browse the repository at this point in the history
  • Loading branch information
faithanalog committed Feb 27, 2021
1 parent eb9f77a commit 11cc4d8
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 20 deletions.
103 changes: 96 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,105 @@ The goal of this project is to make a simple implementation of the core features

- use C
- use xlib
- configuration at compile time / with command line arguments
- IPC via unix signals
- optional features like sound support that can be disabled at compile time
- optional features like sound support

I'm undecided on whether I want to include any GUI whatsoever, as kmousetool already has one if you want one. I might use a minimal UI library to add a GUI, but I don't really want a GTK or QT dependency.


### Planned Features
### Features

[ ] Click mouse after mouse movement stops
[ ] Drag mouse if mouse movement starts shortly after stopping
[ ] Play a sound on mouse click
[x] Unix signals for toggle/enable/disable
- Click mouse after mouse movement stops
- Drag mouse if mouse movement starts shortly after stopping
- Play a sound on mouse click
- defaults to using aplay
- Unix signals for toggle/enable/disable
- SIGHUP = toggle
- SIGUSR1 = enable
- SIGUSR2 = disable
- Status file
- defaults to /tmp/rtmouse-status.txt


#### Planned Features

- Command line arguments
- Better configuration of audio playback method (right now it is just go find the execl call and modify it)


### Dependencies

- a C compiler (should work with gcc, clang, tcc, cproc, etc.)
- libc
- xlib
- aplay, if you want sound. you can also change the audio playback command in the code


### Config

For now, modify `config.h` before building. I'll add a way to use command line
arguments later. The default `config.h` is replicated below:

```c
struct Dwell_Config config =
{
// Minimum movement before a mouse motion activates the dwell timer
.min_movement_pixels = 10,

// rtmouse will wait this long after mouse movement ends before clicking.
// default 500ms. you may want to make it longer
.dwell_time = 500 / TIMER_INTERVAL_MS,

// rtmouse will drag-click if you move the mouse within this timeframe
// after a click occurs.
.drag_time = 500 / TIMER_INTERVAL_MS,

// dragging only happens when this is on
.drag_enabled = true,

// sound plays on click when this is on
.sound_enabled = true,

// status_file will be modified with enabled/disabled/terminated statuses
// when this is on
.write_status = true,
.status_file = "/tmp/rtmouse-status.txt"
};
```


### Install

```bash
./build.sh
sudo ./install.sh
```
This will put `rtmouse` at `/usr/local/bin` and `mouse


### Usage

Run `rtmouse` and it'll start up.

You can use `killall -HUP rtmouse` to toggle enabled/disabled state, or `-USR1/-USR2` to specifically enable and disable it respectively.


#### i3wm

I use i3wm, so here's how I'm integrating rtmouse with that.

I put this in my i3 config:

```
exec --no-startup-id rtmouse
bindsym $mod+z exec --no-startup-id killall -HUP rtmouse && killall -USR1 i3status
```

and then also add this to my i3status config:

```
order += "read_file rtmouse"
read_file rtmouse {
path = "/tmp/rtmouse-status.txt"
}
```
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
cc -Wall -O2 -o rtmouse rtmouse.c -lX11 -lXi -lXtst
24 changes: 24 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
struct Dwell_Config config =
{
// Minimum movement before a mouse motion activates the dwell timer
.min_movement_pixels = 10,

// rtmouse will wait this long after mouse movement ends before clicking.
// default 500ms. you may want to make it longer
.dwell_time = 500 / TIMER_INTERVAL_MS,

// rtmouse will drag-click if you move the mouse within this timeframe
// after a click occurs.
.drag_time = 500 / TIMER_INTERVAL_MS,

// dragging only happens when this is on
.drag_enabled = true,

// sound plays on click when this is on
.sound_enabled = true,

// status_file will be modified with enabled/disabled/terminated statuses
// when this is on
.write_status = true,
.status_file = "/tmp/rtmouse-status.txt"
};
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -v

install --mode 755 -D -t /usr/local/bin rtmouse
install --mode 644 -D -t /usr/local/share/rtmouse mousetool_tap.wav
13 changes: 2 additions & 11 deletions rtmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct Dwell_Config
const char* status_file;
};

#include "config.h"

struct Dwell_State
{
bool active;
Expand All @@ -66,17 +68,6 @@ struct Dwell_State
int xi_extension_opcode;
};

struct Dwell_Config config =
{
.min_movement_pixels = 10,
.dwell_time = 500 / TIMER_INTERVAL_MS,
.drag_time = 500 / TIMER_INTERVAL_MS,
.drag_enabled = true,
.sound_enabled = true,
.write_status = true,
.status_file = "/tmp/rtmouse-status.txt"
};

struct Dwell_State state =
{
.active = true,
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
./build.sh && ./rtmouse

0 comments on commit 11cc4d8

Please sign in to comment.