Animated Nyan Cat for the Touch Bar that reacts to what you're doing (Swift plugin)

Type

Swift plugin

Categories

Touch Bar

Summary

Animated Nyan Cat for the Touch Bar that changes accessories based on what you're doing

Description and setup

Quick vibe-coding session (Claude Code, one evening) to finally do the thing I always wanted to do with my Touch Bar: have a Nyan Cat flying along on the left.

Then it got a little out of hand and the cat started reacting to whatever I'm doing:

  • Music playing → floating notes
  • Terminal / code editor in front → matrix rainbow + hacker shades
  • Design app in front → painter's beret
  • Mic in use (any app, browser calls too) → headset
  • Battery ≤ 20 % → faded rainbow, tired eyes
  • Charging → lightning bolt
  • Midnight to 6 AM → nightcap and zzz
  • CPU above 70 % → sweat drops and the cat runs twice as fast

They stack, so music + terminal = shades and notes.

Fun detail: a GIF as a button icon doesn't animate in BTT (people have been asking for that for years in the "Button animation (.gif) for touchbar" thread), so this is a Swift Touch Bar plugin that swaps frames itself. BTT sits around 1–2 % CPU on my M1.

Setup: drop NyanCat.swift into ~/Library/Application Support/BetterTouchTool/Plugins/, confirm the compile prompt, then add a Touch Bar "Plugin" widget → Nyan Cat, on the left. If your preset has conditional groups (like "Music Playing"), add it there too. To preview a variant, set the BTT variable nyan_forzar to something like musica,terminal (empty = automatic).

Got more ideas? Feel free to vibe code them. The sprites are drawn in code, so a new hat is a few lines in the generator. PRs welcome: GitHub - lahoal/nyan-touchbar: Animated Nyan Cat for the MacBook Pro Touch Bar (BetterTouchTool plugin) that changes accessories based on what you're doing · GitHub

Version

1.0.0

Tested with BetterTouchTool version

6.958

Download

NyanCat.swift (25.1 KB)

Screenshots

touchbar-real.gif

Update: v1.1.0 is out — 13 new moods, triple tap to hide a mood, and trackpad haptics.

New moods

  • Writing / office app in front (or a Google Docs tab) → pencil behind the ear
  • Chat app in front → speech bubble, typing
  • Game or launcher in front → gamepad
  • Video player in front (or a YouTube / Netflix / Twitch tab) → popcorn
  • Camera in use, virtual ones too → tie
  • 5 min without keyboard or mouse → falls asleep, slow motion
  • No network → blinking question mark
  • Mac running hot → the frosting melts
  • 7 to 10 AM → steaming coffee
  • Special days → witch hat (Oct 31), Santa hat (Dec 24–25), party hat and confetti (Dec 31–Jan 1), Chilean chupalla (Sep 18–19)

Triple tap to hide a mood
Tap the cat three times and the decorative stuff on screen (coffee, popcorn, chat bubble, special days) goes away, with a burst of sparkles. It stays hidden until it happens again: coffee comes back tomorrow morning, popcorn the next time you open a video app. Battery, CPU, network, mic and camera can't be hidden, since they actually tell you something.

Tip if your preset has the widget in more than one group (Global and "Music Playing", for example): BTT runs a separate plugin instance per group, so the dismissals are saved to a small file that all instances share. Otherwise the coffee would come back every time the music started or stopped (ask me how I know).

Haptics
Each tap gives a light click on the trackpad, and the triple tap a strong one. The Touch Bar has no haptic engine, and the public API only fires while a finger is on the trackpad, so this uses the trackpad actuator through the private MultitouchSupport framework (same trick as HapticKey). If a macOS update breaks it, the cat just stops vibrating.

Editable app lists
The apps that trigger each mood now live in apps.json: 194 apps across six moods, taken from the most installed Homebrew casks of the last year. Bundle IDs or prefixes (com.jetbrains.*), plus keywords for the browser tab title (so a Penpot or Figma tab counts as design). Copy it to ~/Library/Application Support/NyanCat/apps.json and edit it, and the plugin reloads it on save, no BTT restart.

Upgrading: replace NyanCat.swift in the Plugins folder, confirm the compile prompt, and restart BTT (hot reload doesn't replace widgets that already exist).

Release and full changelog: Release v1.1.0 — 13 new moods, triple tap, haptics · lahoal/nyan-touchbar · GitHub

Next up: pixel-art media buttons inside the widget that the cat reacts to (pause freezes it, next makes it dash forward).