DEV Community

Cover image for How I Built a Linux CLI That Auto-Pauses Your "Active Time"
fralsare
fralsare

Posted on

How I Built a Linux CLI That Auto-Pauses Your "Active Time"

A few weeks ago I wanted something simple: a way to see how much of my day I was actually using my computer versus just sitting at it. My existing time trackers counted every idle minute as wasted, which felt wrong - I wasn't being lazy, I was just… not doing anything.

So I built timerCLI, a tiny command-line tool that tracks your active time and automatically pauses it whenever you go idle.

The core idea

The trick is simple but clever: Linux exposes raw input device events at /dev/input/event*. These are the kernel-level files that capture every keyboard press, mouse movement, and touch event.

All timerCLI does is:

Open every readable /dev/input/event* device (non-blocking)
Continuously drain any pending input events
Track the timestamp of the last event
If no input arrives for IDLE_LIMIT seconds (default 30s), pause the timer
Resume the instant input returns
That's the entire engine — no machine-learning, no tracking servers, no telemetry. Just raw input watching.

What the output looks like

Idle: 0s | Active: 00:04
⏸ Idle 31s — pausing…
▶ Resumed.
Idle: 0s | Active: 00:41 ← keeps counting down while paused

When you stop typing/moving for 30 seconds, it pauses and shows a ⏸️ indicator. The moment you use your computer, it's back to counting active time. Stop it anytime with Ctrl+C and it prints your final active/paused totals.

Why keep it tiny?

I deliberately wrote this using only Python's standard library - no psutil, no pyautogui, no dependencies to install. That means:

It runs on almost any Linux box with Python 3
Nothing to pip install
Easy to read and modify
The only real requirement is permission to read /dev/input/event*, which needs your user in the input group:

sudo usermod -aG input $USER # then log out and back in

It's open source

timerCLI is MIT licensed and fully open source. You can read the whole thing in a few hundred lines here:

👉 timerCLI

I built it as a learning project, but I'd love for people to actually use it. I'm also accepting donations (GitHub Sponsors + UPI) to fund my cybersecurity studies - every bit helps. 🙏

Top comments (0)