Skip to content

Prastavna/clean-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clean-mode

A cross-platform CLI tool that temporarily disables keyboard and touchpad input so you can wipe your devices clean without triggering accidental keypresses.

How it works

When activated, clean-mode disables all keyboard and touchpad/trackpad input for a configurable duration (default 10 seconds), displays a countdown timer, then re-enables everything automatically.

If the process is interrupted (Ctrl+C or SIGTERM), inputs are always re-enabled before exit.

Platform support

Platform Mechanism Prerequisites
Linux xinput disable / xinput enable X11 session, xinput installed
macOS hidutil property --set (UserKeyMapping) None
Windows BlockInput Win32 API Must run as Administrator

Installation

Requires Go 1.25+.

go build -o clean-mode .

Cross-compile for other platforms:

GOOS=darwin  GOARCH=arm64 go build -o clean-mode-macos .
GOOS=windows GOARCH=amd64 go build -o clean-mode.exe .

Usage

Direct mode (default)

Activates immediately, disables inputs for the duration, then exits.

./clean-mode

Custom duration

Set the countdown duration in seconds with -t:

./clean-mode -t 15

Interactive mode

Keeps running and waits for you to press ENTER each time you want to activate a cleaning cycle. Useful if you clean your keyboard frequently during a session.

./clean-mode -i

Flags

Flag Default Description
-t 10 Duration in seconds
-i false Interactive mode (wait for ENTER, repeatable)

Examples

# Quick 5-second wipe
./clean-mode -t 5

# 20-second deep clean
./clean-mode -t 20

# Stay open, activate with ENTER whenever needed
./clean-mode -i

# Interactive mode with 15-second cycles
./clean-mode -i -t 15

Platform-specific notes

Linux

  • Requires an X11 session (xinput does not work under Wayland).
  • Install xinput if not present: sudo apt install xinput (Debian/Ubuntu) or sudo pacman -S xorg-xinput (Arch).
  • The tool auto-discovers keyboards and touchpads by parsing xinput list.

macOS

  • Uses hidutil to remap modifier keys to null events. No sudo required.
  • The key remapping is cleared when inputs are re-enabled.
  • Trackpad hardware clicks still work (there is no unprivileged way to fully block them on macOS); software gestures are unaffected during the short cleaning window.

Windows

  • The BlockInput API requires the process to run with Administrator privileges. Right-click the executable and select "Run as administrator", or launch from an elevated terminal.
  • Blocks all keyboard and mouse input system-wide for the duration.

Safety

  • Signal handling: Ctrl+C or SIGTERM during an active countdown will always re-enable inputs before exiting.
  • Automatic restore: Inputs are unconditionally re-enabled when the countdown reaches zero.
  • No persistent changes: Nothing is written to disk or modified permanently. On Linux and macOS, device state returns to exactly what it was before activation.

Running tests

go test ./...

With race detection:

go test -race ./...

Project structure

clean-mode/
  main.go                  Entry point, CLI flags, orchestration
  main_test.go             Integration tests (mock blocker)
  blocker/
    blocker.go             InputBlocker interface, DeviceInfo types
    blocker_linux.go       Linux implementation (xinput)
    blocker_darwin.go      macOS implementation (hidutil)
    blocker_windows.go     Windows implementation (BlockInput)
    factory_{os}.go        Platform-specific constructor
    blocker_linux_test.go  xinput parsing and mock tests
  timer/
    timer.go               Countdown with injectable sleeper
    timer_test.go          Timer unit tests
  display/
    display.go             Terminal output (box drawing, progress bar)
    display_test.go        Display unit tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages