How oniatsu/hotswitch-hs works
Project Type and Purpose
• HotSwitch-HS is a macOS utility that replaces the system window switcher by using a customized hotkey mechanism integrated with Hammerspoon.
• The README explains its operation—registering a fixed key to windows and then switching between them via that key—and hints at its two main phases: key/registration handling and window switching.
• The project is not a traditional full-stack system but rather a focused desktop tool that leverages macOS “glue” software (Hammerspoon) to interact with windows.
File Structure for Key Architectural Insights
• The “lib” directory is divided into several key parts:
– /lib/common: Contains generic utilities (like constants for canvas, debugging, frame calculations, time checks, and updating) that support the overall operations.
– /lib/controller: Contains the MainController and HotkeyController, which likely serve to orchestrate the interactions between user input and internal logic.
– /lib/model: Includes different model files (the AppWatchModel, KeyStatusModel, PreferenceModel, etc.) that represent application data – the current window states, user settings, and key registrations.
– /lib/view: Contains the view components (BaseCanvasView, PanelLayoutView, SelectedRowCanvasView, ToastView) responsible for displaying the panel and window information.
• The main entry point appears to be the “hotswitch-hs.lua” file, which ties the module to Hammerspoon.