$ show f-person/auto-dark-mode.nvim
auto-dark-mode.nvim is a Neovim plugin that automatically switches the editor's background between dark and light mode based on the host operating system's appearance setting. It supports macOS (via `defaults read`), Linux (via `dbus-send` with optional `dbus-monitor` for event-driven updates), Windows (via `reg.exe`), and WSL/OrbStack. The plugin polls the system at a configurable interval (default 3000ms) or uses D-Bus monitoring on Linux for immediate updates. It provides user-definable callback functions (`set_dark_mode` and `set_light_mode`) that default to changing Neovim's `background` option. The architecture is modular: `init.lua` handles OS detection and setup, `interval.lua` manages polling/monitoring and theme synchronization, `health.lua` provides a `:checkhealth` diagnostic with benchmarking, and `types.lua` defines type annotations. The code is well-structured with graceful fallbacks for older Neovim versions (0.7.x) and comprehensive error handling for edge cases like running as root or missing system utilities. It is a focused, single-purpose plugin with clean separation of concerns.
The LLM identified 1 files worth highlighting for reuse:
This module implements the core polling and monitoring logic for detecting system appearance changes. It provides two mechanisms: a timer-based poll using `vim.system` (or legacy `vim.fn.jobstart`) and an event-driven monitor using `dbus-monitor` on Linux. The module handles parsing of system-specific command output, deduplication of theme changes, and safe scheduling of user callbacks. It demonstrates a clean pattern for asynchronous system command execution with fallback support for older Neovim versions, and includes proper cleanup on VimLeave. While tightly coupled to the plugin's state and options, the structure is a good reference for implementing similar system-state polling in Neovim plugins.