COSMIC panel applet that toggles between light and dark theme with a single click on a systray icon.
It works by flipping the content of
$XDG_CONFIG_HOME/cosmic/com.system76.CosmicTheme.Mode/v1/is_dark
(default: $HOME/.config/...) between true and false, which is what COSMIC
watches to switch modes.
sudo apt install cargo cmake just libexpat1-dev libfontconfig-dev \
libfreetype-dev libxkbcommon-dev pkgconfFrom the repo root:
just build # cargo build --release
just install # copy binary + .desktop + icon into $HOME/.local
just reload-panel # restart cosmic-panel so it rescans appletsThen open COSMIC Settings → Desktop → Panel → Add applet and add "COSMIC Theme Switch".
To uninstall:
just uninstallMake sure
$HOME/.local/binis on yourPATH; the.desktopfile relies on that for itsExec=cosmic-theme-switcherentry.
To install somewhere else (e.g. system-wide), override PREFIX:
sudo just PREFIX=/usr/local installjust run # cargo run --releasesrc/theme_io.rs— read/write theis_darkfile (unit-tested)src/icons.rs— embedded Sun/Moon SVGssrc/app.rs—cosmic::Applicationimplementationsrc/main.rs— entry pointdata/— panel metadata and icon assets

