Skip to content

holo-q/cosmic-applet-lightdark-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COSMIC Light/Dark Theme Toggle Applet

A simple panel applet for the COSMIC desktop environment that provides one-click toggling between light and dark system themes.

Features

  • 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

Architecture

The applet leverages COSMIC's configuration system:

  • Uses libcosmic for 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) and weather-clear-night-symbolic (moon)

Requirements

  • COSMIC desktop environment (Pop!_OS 24.04+ or cosmic-epoch)
  • Rust toolchain (1.70+)
  • libcosmic development dependencies

Building

cargo build --release

The compiled binary will be at target/release/cosmic-applet-lightdark-switch

Installation

Manual Installation

# 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.desktop

Using just (if available)

If the COSMIC ecosystem's just recipes are set up:

just install

Usage

  1. After installation, restart the COSMIC panel or log out and back in
  2. Right-click on the panel and select "Add Applet"
  3. Find "Light/Dark Theme Toggle" in the applet list
  4. Click to add it to your panel
  5. 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

Development

The applet follows COSMIC's applet architecture:

  • Implements cosmic::Application for core logic
  • Implements cosmic::applet::Applet for panel integration
  • Uses cosmic-config to persist theme preferences
  • Subscribes to config changes for external updates

Key Files

  • src/main.rs: Main applet implementation with theme toggle logic
  • Cargo.toml: Dependencies and build configuration
  • data/*.desktop: Desktop entry for applet discovery

Debugging

Run with logging enabled:

RUST_LOG=cosmic_applet_lightdark_switch=debug cargo run

License

This project follows the same license as libcosmic (MPL-2.0).

Contributing

Contributions welcome! Feel free to open issues or submit pull requests.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published