A simple panel applet for the COSMIC desktop environment that provides one-click toggling between light and dark system themes.
- Quick Toggle: Single click to switch between light and dark themes
- Visual Feedback: Shows a sun icon in light mode and moon icon in dark mode
- Automatic Updates: Icon updates when theme is changed from other sources (e.g., Settings app)
- Lightweight: Minimal resource usage, integrates seamlessly with COSMIC panel
The applet leverages COSMIC's configuration system:
- Uses
libcosmicfor panel integration and UI components - Reads/writes theme preferences via
cosmic-config - Subscribes to theme changes for real-time updates
- Displays symbolic icons:
weather-clear-symbolic(sun) andweather-clear-night-symbolic(moon)
- COSMIC desktop environment (Pop!_OS 24.04+ or cosmic-epoch)
- Rust toolchain (1.70+)
- libcosmic development dependencies
cargo build --releaseThe compiled binary will be at target/release/cosmic-applet-lightdark-switch
# Build the applet
cargo build --release
# Install the binary
sudo install -Dm755 target/release/cosmic-applet-lightdark-switch /usr/bin/cosmic-applet-lightdark-switch
# Install the desktop entry
sudo install -Dm644 data/com.system76.CosmicAppletLightDarkSwitch.desktop \
/usr/share/applications/com.system76.CosmicAppletLightDarkSwitch.desktopIf the COSMIC ecosystem's just recipes are set up:
just install- After installation, restart the COSMIC panel or log out and back in
- Right-click on the panel and select "Add Applet"
- Find "Light/Dark Theme Toggle" in the applet list
- Click to add it to your panel
- Click the applet icon to toggle between light and dark themes
The icon will show:
- Sun when in light mode
- Moon when in dark mode
The applet follows COSMIC's applet architecture:
- Implements
cosmic::Applicationfor core logic - Implements
cosmic::applet::Appletfor panel integration - Uses
cosmic-configto persist theme preferences - Subscribes to config changes for external updates
src/main.rs: Main applet implementation with theme toggle logicCargo.toml: Dependencies and build configurationdata/*.desktop: Desktop entry for applet discovery
Run with logging enabled:
RUST_LOG=cosmic_applet_lightdark_switch=debug cargo runThis project follows the same license as libcosmic (MPL-2.0).
Contributions welcome! Feel free to open issues or submit pull requests.