feat/monochrome-icon #15

Merged
nabaxo merged 6 commits from feat/monochrome-icon into main 2026-04-29 12:44:05 +02:00
Owner

Add monochrome icon option

Add monochrome icon option
Adds a  setting that renders the tray icon as a monochrome glyph
which adapts to the active system color scheme.

Linux: serve the icon through StatusNotifierItem's IconPixmap (empty IconName
so Plasma can't auto-substitute a  theme icon). The symbolic variant
is retinted at runtime to match  from
, emulating SVG  without a runtime SVG parser. An
inotify watcher on  re-emits NewIcon on color-scheme changes so
the tray updates live. Also re-emits on config reload.

Windows: embed separate black/white ICOs (icon-b / icon-w) and swap live on
WM_SETTINGCHANGE when AppsUseLightTheme flips.

Ships icon-symbolic.svg and icon-{b,w}.ico as accompanying assets; generalises
the inotify helper into  so watchers beyond the
config file can reuse it.
The inotify thread, tokio task, and mpsc channel are pure waste for the
default colored-icon case. Gating the spawn on config.window.mono_icon
reclaims ~20 KiB RSS at startup. Runtime flips to true still retint on
the next config reload; subsequent theme changes need a daemon restart.
For mono_icon=false, serve IconName=janq with an empty pixmap so Plasma
resolves the icon from the hicolor theme and never touches the embedded
ARGB blobs. For mono_icon=true, keep the pixmap path (empty IconName,
recolored symbolic) so Plasma can't substitute a -symbolic theme icon.

Also drop the unused COLORED const + colored_*.argb build artifacts
(LTO now strips them entirely), and emit icon_pixmap_changed alongside
icon_name_changed in emit_new_icon so kdeglobals-triggered retints
actually reach Plasma.

Brings default-case RSS from +56 KiB to +20 KiB over main; mono_icon=true
adds another +8 KiB for the watcher infrastructure.
Adds  and  alongside the existing
option, so users can opt into the monochrome tray icon only in one system
mode (e.g. colored panel in light mode, mono in dark). The existing
 continues to force mono in both modes.

WindowConfig gains two helpers:
  - wants_mono(is_dark) — resolves effective mono state for the current theme
  - any_mono()          — true if any mono flag is set (used to gate optional
                          startup plumbing like the Linux kdeglobals watcher)

Linux: the SNI getters and the watcher spawn now route through wants_mono
/any_mono. Theme detection reads [Colors:Window] BackgroundNormal (primary),
falls back to ForegroundNormal then [General] ColorScheme= name matching.
The is_dark value is cached in an AtomicBool; refresh_theme_cache() is the
only path that reads kdeglobals, called once per inotify event — and returns
false when the value didn't flip, so KConfig's multi-pass section rewrites
don't cause redundant NewIcon emissions. Property getters are now a single
atomic load, so Plasma's aggressive polling costs nothing between switches.

Windows: initial icon selection, config-reload, and WM_SETTINGCHANGE paths
all go through wants_mono(is_dark_mode()). ThemeChanged now also repaints
when crossing out of mono (previously only repainted if mono_icon was
always-on).

Docs (README, PROJECT_CONTEXT, CHANGELOG) updated to describe the three
flags and their interaction.
- Implement 1bpp alpha-only storage for tray icons to reduce binary bloat
- Add runtime ARGB expansion with automatic tinting based on KDE theme
- Implement robust, single-pass kdeglobals parser for theme/color detection
- Add atomic theme caching to avoid syscalls on SNI property getters
- Ensure immediate icon refresh via inotify and D-Bus NewIcon signal
- Limit BackgroundNormal/ForegroundNormal extraction to window section
- Prevent false is_dark detections from light Header/Button colors
- Ensure consistent symbolic icon tinting across all Plasma themes
nabaxo merged commit 370532d945 into main 2026-04-29 12:44:05 +02:00
nabaxo deleted branch feat/monochrome-icon 2026-04-29 12:44:05 +02:00
nabaxo referenced this pull request from a commit 2026-04-29 12:44:05 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nabaxo/janq!15
No description provided.