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.
Requires libevdev-devel (Fedora: sudo dnf install libevdev-devel).
make
Compiles ctrlw.c → ctrlw in this directory.
| 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 |
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.
/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.
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.
- 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.
ctrlw.c— source (poll(2) loop + uinput; no X11)Makefile— build/install:make,sudo make install,make checkcheck.sh— themake checkleak/memory test runnerman/ctrlw.1— manual page (installed bymake install)tldr/ctrlw.md— tldr page (installed bymake tldr-install)ctrlw-run— wrapper that adds theinputgroup viasg
- If you remap the side buttons in input-remapper presets, those presses are consumed there and never reach ctrlw.
MIT