Skip to content
neunmalelfPublic

About

Mouse button 4 (BTN_SIDE) sends Ctrl+W - evdev + uinput, no X dependency (Wayland/X11)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ctrlw

Mouse button 4 (BTN_SIDE) sends Ctrl+W to the active window. Works on Wayland and X11 — no X dependency: it reads evdev input devices and emits keys through a uinput virtual keyboard.

Build

Requires libevdev-devel (Fedora: sudo dnf install libevdev-devel).

make

Compiles ctrlw.c → ctrlw in this directory.

Make reference

Target Effect
make / make all build ./ctrlw
make check valgrind leak check + ASan memory-error smoke test
make install setgid install of the binary + man page — run as: sudo make install
make uninstall remove the installed binary and man page
make tldr-install install the tldr page to the user tldr cache (no root)
make clean remove build artifacts
make help show all targets

Overridable variables:

Variable Default Meaning
CC gcc compiler
CFLAGS -O2 -Wall -Wextra extra compiler flags, e.g. make CFLAGS='-O0 -g' for a debug build
PREFIX /usr/local install prefix
BINDIR $(PREFIX)/bin install directory
MANDIR $(PREFIX)/share/man/man1 man page install directory
TLDIR $(HOME)/.local/share/tldr/pages/linux tldr page install directory
GROUP input setgid group of the installed binary
DESTDIR (empty) staging root for installs, e.g. make install DESTDIR=/tmp/stage

Testing

make check

Runs the program under valgrind (full leak check, 10 s) and an AddressSanitizer build (memory errors, 5 s). Fails the check if there are leaks or errors. Missing tools are reported with the install command:

sudo dnf install valgrind libasan    # Fedora

make check binds the real mice when your user is in the input group (sg), otherwise it runs without device access and says so.

Permissions

/dev/input/event* and /dev/uinput are root:input 0660. Either add your user to the input group (needs re-login), or use a setgid install — preferred, works for everyone with no group membership:

sudo make install

(same as: sudo install -m 2755 -g input ctrlw /usr/local/bin/ctrlw)

Re-run after every recompile: install copies the new build over the old one (keeping the setgid bit and input group). Remove with sudo make uninstall.

Run

ctrlw                  # installed setgid binary — no group needed
./ctrlw-run            # workspace build, adds the input group via sg (no re-login)
./ctrlw                # workspace build, needs input group (current session: re-login)
ctrlw --help           # short usage, from the binary
man ctrlw              # full manual page (after make install)
tldr ctrlw             # tldr page (after: sudo dnf install tealdeer, make tldr-install)

Stop with Ctrl+C; the virtual keyboard is removed automatically.

Behavior

  • Binds every mouse that exposes BTN_SIDE (button 4), so the binding works whichever mouse is used.
  • On press sends: Ctrl down, W down, W up, Ctrl up.

Files

  • ctrlw.c — source (poll(2) loop + uinput; no X11)
  • Makefile — build/install: make, sudo make install, make check
  • check.sh — the make check leak/memory test runner
  • man/ctrlw.1 — manual page (installed by make install)
  • tldr/ctrlw.md — tldr page (installed by make tldr-install)
  • ctrlw-run — wrapper that adds the input group via sg

Notes

  • If you remap the side buttons in input-remapper presets, those presses are consumed there and never reach ctrlw.

License

MIT

About

Mouse button 4 (BTN_SIDE) sends Ctrl+W - evdev + uinput, no X dependency (Wayland/X11)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages