DEV Community

whoisnaisu
whoisnaisu

Posted on Fully Autonomous

I turned Claude Code hooks into a pixel-art desk clock

Glance: a session asks for permission, the panel shows what each session and its subagents are doing, another session finishes

Glance is a tiny pixel-art clock that sits on my desktop and shows, at a glance, how my Claude Code sessions are doing: working, waiting on me, or done. It also shows what each one is doing right now, the subagents it's running, my plan limits and today's tokens.

This post is about how it works, because the thing that makes it possible, Claude Code hooks, is useful well beyond a clock.

Hooks in one paragraph

Claude Code can run a command of yours whenever something happens in a session: a prompt is sent, a tool is about to run, Claude needs permission, a turn ends. You list them in ~/.claude/settings.json, and each one gets the event as JSON on stdin. Glance registers the same small command for every event it cares about:

{
  "hooks": {
    "PreToolUse": [
      { "hooks": [{ "type": "command", "command": "C:\\...\\glance.exe", "args": ["hook", "--glance"] }] }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

glance hook reads the event, updates one small JSON file per session in ~/.glance/sessions/, and exits. The clock reads that folder every 1.5 seconds. No server in between.

From events to states

Event What the clock shows
UserPromptSubmit working, and your prompt becomes the session's subtitle
PreToolUse working, plus the current step ("Editing src/checkout.ts")
PreToolUse for AskUserQuestion or ExitPlanMode waiting: has a question, or a plan is ready for review
Notification with permission_prompt waiting: needs permission
Stop done
StopFailure stopped on an error
SubagentStart / SubagentStop the session's running agents
SessionEnd the session goes away

A step is a short sentence built from the tool call: Read becomes "Reading X", Edit becomes "Editing X", a shell command shows its description or its first line, Grep becomes "Searching for …". Paths are shown relative to the project. The status file only ever holds that sentence, never file contents.

Things that weren't obvious

Subagents fire the same hooks. Events from inside a subagent carry an agent_id. Treat them like the main session's and a background agent's tool call flips a finished session back to "working". Glance keeps one file per agent instead (~/.glance/agents/<session>/<agent>.json), and an agent's events only touch the session when they show a permission prompt was answered.

Not every prompt is yours. When a background agent reports back, that also arrives as UserPromptSubmit, with text that starts with <task-notification> or <agent-message>. Glance skips those, so the subtitle keeps the prompt you actually typed.

A turn can end while agents keep working. Stop comes with a background_tasks list. Glance clears a session's agents only when that list is empty, so background work stays on the clock after the main turn is done.

Interrupted turns send no Stop. About a minute after Claude goes idle, a Notification with idle_prompt arrives, and Claude Code sends it only once no background agent is running. Glance uses it to mark a session done if it still says "working".

"Waiting" isn't instant, and that's good. The permission Notification arrives only after a prompt has gone unanswered for a few seconds, so a permission you grant straight away never shows up as waiting. The clock only nags when you've actually looked away.

Hooks run at the same time. Several can fire at once, so every write goes to a temp file that is then renamed into place. A reader never sees half a file.

The clock itself

Glance is a Tauri 2 app with a TypeScript front end. All the pixel art (digits, icons, bars) is drawn as SVG rectangles sized in whole device pixels, so it stays sharp at any Windows display scaling. There are five themes, including one on the PICO-8 palette and one in the original Game Boy's four greens, a flat bar layout for over games, and Ctrl+Alt+G hides it to a single dot.

Plan limits come from Claude Code's status line: Glance can set it to glance statusline, which saves your 5-hour and weekly usage for the clock.

Try it

Glance is free, for Windows 10 and 11: github.com/whoisnaisu/glance. Connect backs up your settings.json before adding its hooks, and Disconnect removes only those. The README lists everything it touches.

The source isn't public, but bug reports and ideas are welcome in Issues. And if you've built something on hooks too, I'd like to see it.

Top comments (0)