Reworks the example into a pure desktop-pet: the cat wanders, sits, grooms, stretches, dashes and naps, reacts to petting and dragging, and follows the cursor with its eyes. The window-scanning and Accessibility code is gone. The cat is drawn from rounded primitives plus Shape paths in a fixed 100x90 design space, so it scales cleanly to any size. Linux/X11 is the primary target: the tray is optional, Wayland gets a warning, and WORKCAT_X11_BYPASS / WORKCAT_OPAQUE cover uncooperative window managers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
3.2 KiB
Workcat (Qt Quick / CMake example)
A little cat that wanders along the bottom edge of your screen, sits down, grooms itself, stretches, dashes off and takes naps. Drag it around, click to pet it, and it purrs. It does nothing else — no window closing, no monitoring.
Inspired by workcat.app, rebuilt as a plain Qt 6 / QML project. Primary target is Linux / X11; development happens on macOS and both are supported by the same code.
Layout
| Path | Purpose |
|---|---|
CMakeLists.txt |
qt_add_executable + qt_add_qml_module (URI Workcat), macOS bundle, .desktop file on Linux |
src/main.cpp |
Wires AppSettings and CatController into the QML engine, warns on Wayland |
src/catcontroller.* |
Mood machine (walk, run, sit, groom, stretch, sleep, love, alert), movement tick, cursor tracking |
src/appsettings.* |
QSettings-backed coat, size, pace, eye tracking, pet counter |
src/platforminfo.* |
QML singleton Platform: platform name plus the two X11 escape hatches |
src/traycontroller.* |
Tray icon and menu, silently skipped when the desktop has no tray |
qml/Main.qml |
Frameless, transparent, always-on-top window that is the cat |
qml/Cat.qml |
The drawing: rounded primitives plus Shape paths for tail, ears and mouth |
qml/SettingsWindow.qml |
Coat swatches, size, pace, eye tracking, trick buttons |
The cat is drawn in a fixed 100 x 90 design space and scaled by width / 100,
so every size setting stays crisp. There are no image assets.
Build
macOS with the Qt online installer:
~/Qt/6.11.1/macos/bin/qt-cmake -S . -B build -G Ninja -DCMAKE_MAKE_PROGRAM=$HOME/Qt/Tools/Ninja/ninja
Linux with distribution Qt packages:
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
Needs Qt 6.8 or newer for Shape.CurveRenderer. Required modules: Core, Gui,
Quick, QuickControls2, Widgets. Widgets is only there because QSystemTrayIcon
needs it for its context menu.
Running on X11
The cat is a frameless, transparent, always-on-top Qt::Tool window that places
itself. Two environment variables cover the cases where a window manager
disagrees:
| Variable | Effect |
|---|---|
WORKCAT_X11_BYPASS=1 |
Adds Qt::X11BypassWindowManagerHint, making an override-redirect window. Use when the WM refuses to keep the cat on top or shows it in the taskbar. |
WORKCAT_OPAQUE=1 |
Paints a solid background instead of relying on transparency. Use when no compositor runs and the cat sits in a black box. |
WORKCAT_POSE=Sitting |
Freezes the cat in one mood. Handy for screenshots. Accepts any CatController::Mood name. |
Wayland cannot let a client position its own window, so the cat would stay
wherever the compositor puts it. The app prints a warning and suggests
QT_QPA_PLATFORM=xcb.
Desktops without a status-notifier host get no tray icon. The cat itself stays the entry point: right-click or double-click opens the settings window.
Interaction
| Input | Result |
|---|---|
| Click | Pet the cat, it closes its eyes and purrs |
| Drag | Pick the cat up and put it somewhere else |
| Hover | Blush and purr wiggle |
| Double-click or right-click | Settings window |
| Tray menu | Tricks, nap toggle, settings, quit |