monocoat 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- monocoat/__init__.py +9 -0
- monocoat/__main__.py +4 -0
- monocoat/acceptance/__init__.py +21 -0
- monocoat/acceptance/__main__.py +51 -0
- monocoat/acceptance/gtk3_review.py +204 -0
- monocoat/acceptance/known_failures.py +81 -0
- monocoat/acceptance/palettes.py +154 -0
- monocoat/acceptance/preset_switch.py +634 -0
- monocoat/acceptance/report.py +86 -0
- monocoat/acceptance/safety.py +121 -0
- monocoat/acceptance/shots.py +156 -0
- monocoat/acceptance/surfaces.py +668 -0
- monocoat/acceptance/world.py +392 -0
- monocoat/appchoices.py +171 -0
- monocoat/appids.py +127 -0
- monocoat/appscan.py +524 -0
- monocoat/appsedit.py +150 -0
- monocoat/backdrop.py +3400 -0
- monocoat/backup.py +1250 -0
- monocoat/bundleprepare.py +90 -0
- monocoat/bundles.py +554 -0
- monocoat/capabilities.py +253 -0
- monocoat/change.py +706 -0
- monocoat/cli.py +2381 -0
- monocoat/commands/__init__.py +0 -0
- monocoat/commands/backup.py +145 -0
- monocoat/commands/daynight.py +79 -0
- monocoat/commands/demo.py +159 -0
- monocoat/commands/import_mydockfinder.py +392 -0
- monocoat/commands/init.py +389 -0
- monocoat/commands/migrate.py +569 -0
- monocoat/commands/perf.py +110 -0
- monocoat/commands/update.py +30 -0
- monocoat/commands/wallpaper.py +380 -0
- monocoat/config.py +86 -0
- monocoat/corners.py +164 -0
- monocoat/cursors.py +162 -0
- monocoat/cursorthemes.py +175 -0
- monocoat/daemons.py +1805 -0
- monocoat/data/hackneyed/ATTRIBUTION +9 -0
- monocoat/data/hackneyed/LICENSE +24 -0
- monocoat/data/hackneyed/hotspots/X_cursor.in +1 -0
- monocoat/data/hackneyed/hotspots/alias.in +1 -0
- monocoat/data/hackneyed/hotspots/all-scroll.in +1 -0
- monocoat/data/hackneyed/hotspots/based_arrow_down.in +1 -0
- monocoat/data/hackneyed/hotspots/based_arrow_up.in +1 -0
- monocoat/data/hackneyed/hotspots/bottom_tee.in +1 -0
- monocoat/data/hackneyed/hotspots/center_ptr.in +1 -0
- monocoat/data/hackneyed/hotspots/closedhand.in +1 -0
- monocoat/data/hackneyed/hotspots/coffee_mug.in +1 -0
- monocoat/data/hackneyed/hotspots/color-picker.in +1 -0
- monocoat/data/hackneyed/hotspots/context-menu.in +1 -0
- monocoat/data/hackneyed/hotspots/copy.in +1 -0
- monocoat/data/hackneyed/hotspots/crosshair.in +1 -0
- monocoat/data/hackneyed/hotspots/default.in +1 -0
- monocoat/data/hackneyed/hotspots/dnd-move.in +1 -0
- monocoat/data/hackneyed/hotspots/draft.in +1 -0
- monocoat/data/hackneyed/hotspots/draped_box.in +1 -0
- monocoat/data/hackneyed/hotspots/e-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/ew-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/exchange.in +1 -0
- monocoat/data/hackneyed/hotspots/help.in +1 -0
- monocoat/data/hackneyed/hotspots/left_tee.in +1 -0
- monocoat/data/hackneyed/hotspots/ll_angle.in +1 -0
- monocoat/data/hackneyed/hotspots/lr_angle.in +1 -0
- monocoat/data/hackneyed/hotspots/move.in +1 -0
- monocoat/data/hackneyed/hotspots/n-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/ne-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/nesw-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/no-drop.in +1 -0
- monocoat/data/hackneyed/hotspots/not-allowed.in +1 -0
- monocoat/data/hackneyed/hotspots/ns-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/nw-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/nwse-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/openhand.in +1 -0
- monocoat/data/hackneyed/hotspots/pencil.in +1 -0
- monocoat/data/hackneyed/hotspots/pirate.in +1 -0
- monocoat/data/hackneyed/hotspots/plus.in +1 -0
- monocoat/data/hackneyed/hotspots/pointer.in +1 -0
- monocoat/data/hackneyed/hotspots/progress.in +1 -0
- monocoat/data/hackneyed/hotspots/right_ptr.in +1 -0
- monocoat/data/hackneyed/hotspots/right_tee.in +1 -0
- monocoat/data/hackneyed/hotspots/s-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/sb_down_arrow.in +1 -0
- monocoat/data/hackneyed/hotspots/sb_left_arrow.in +1 -0
- monocoat/data/hackneyed/hotspots/sb_right_arrow.in +1 -0
- monocoat/data/hackneyed/hotspots/sb_up_arrow.in +1 -0
- monocoat/data/hackneyed/hotspots/se-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/split_h.in +1 -0
- monocoat/data/hackneyed/hotspots/split_v.in +1 -0
- monocoat/data/hackneyed/hotspots/sw-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/text.in +1 -0
- monocoat/data/hackneyed/hotspots/top_tee.in +1 -0
- monocoat/data/hackneyed/hotspots/ul_angle.in +1 -0
- monocoat/data/hackneyed/hotspots/ur_angle.in +1 -0
- monocoat/data/hackneyed/hotspots/vertical-text.in +1 -0
- monocoat/data/hackneyed/hotspots/w-resize.in +1 -0
- monocoat/data/hackneyed/hotspots/wait.in +1 -0
- monocoat/data/hackneyed/hotspots/wayland-cursor.in +1 -0
- monocoat/data/hackneyed/hotspots/zoom-in.in +1 -0
- monocoat/data/hackneyed/hotspots/zoom-out.in +1 -0
- monocoat/data/hackneyed/hotspots/zoom.in +1 -0
- monocoat/data/hackneyed/svg/X_cursor.svg +224 -0
- monocoat/data/hackneyed/svg/alias.svg +263 -0
- monocoat/data/hackneyed/svg/all-scroll.svg +235 -0
- monocoat/data/hackneyed/svg/based_arrow_down.svg +226 -0
- monocoat/data/hackneyed/svg/based_arrow_up.svg +226 -0
- monocoat/data/hackneyed/svg/bottom_tee.svg +226 -0
- monocoat/data/hackneyed/svg/center_ptr.svg +230 -0
- monocoat/data/hackneyed/svg/closedhand.svg +252 -0
- monocoat/data/hackneyed/svg/coffee_mug.svg +289 -0
- monocoat/data/hackneyed/svg/color-picker.svg +261 -0
- monocoat/data/hackneyed/svg/context-menu.svg +304 -0
- monocoat/data/hackneyed/svg/copy.svg +258 -0
- monocoat/data/hackneyed/svg/crosshair.svg +225 -0
- monocoat/data/hackneyed/svg/default.svg +252 -0
- monocoat/data/hackneyed/svg/dnd-move.svg +260 -0
- monocoat/data/hackneyed/svg/draft.svg +278 -0
- monocoat/data/hackneyed/svg/draped_box.svg +241 -0
- monocoat/data/hackneyed/svg/e-resize.svg +226 -0
- monocoat/data/hackneyed/svg/ew-resize.svg +226 -0
- monocoat/data/hackneyed/svg/exchange.svg +262 -0
- monocoat/data/hackneyed/svg/help.svg +292 -0
- monocoat/data/hackneyed/svg/left_tee.svg +226 -0
- monocoat/data/hackneyed/svg/ll_angle.svg +226 -0
- monocoat/data/hackneyed/svg/lr_angle.svg +226 -0
- monocoat/data/hackneyed/svg/move.svg +224 -0
- monocoat/data/hackneyed/svg/n-resize.svg +226 -0
- monocoat/data/hackneyed/svg/ne-resize.svg +206 -0
- monocoat/data/hackneyed/svg/nesw-resize.svg +333 -0
- monocoat/data/hackneyed/svg/no-drop.svg +258 -0
- monocoat/data/hackneyed/svg/not-allowed.svg +230 -0
- monocoat/data/hackneyed/svg/ns-resize.svg +226 -0
- monocoat/data/hackneyed/svg/nw-resize.svg +208 -0
- monocoat/data/hackneyed/svg/nwse-resize.svg +226 -0
- monocoat/data/hackneyed/svg/openhand.svg +252 -0
- monocoat/data/hackneyed/svg/pencil.svg +256 -0
- monocoat/data/hackneyed/svg/pirate.svg +252 -0
- monocoat/data/hackneyed/svg/plus.svg +223 -0
- monocoat/data/hackneyed/svg/pointer.svg +252 -0
- monocoat/data/hackneyed/svg/progress-1.svg +282 -0
- monocoat/data/hackneyed/svg/progress-10.svg +327 -0
- monocoat/data/hackneyed/svg/progress-11.svg +327 -0
- monocoat/data/hackneyed/svg/progress-12.svg +327 -0
- monocoat/data/hackneyed/svg/progress-13.svg +327 -0
- monocoat/data/hackneyed/svg/progress-14.svg +327 -0
- monocoat/data/hackneyed/svg/progress-15.svg +332 -0
- monocoat/data/hackneyed/svg/progress-16.svg +327 -0
- monocoat/data/hackneyed/svg/progress-2.svg +283 -0
- monocoat/data/hackneyed/svg/progress-3.svg +283 -0
- monocoat/data/hackneyed/svg/progress-4.svg +283 -0
- monocoat/data/hackneyed/svg/progress-5.svg +280 -0
- monocoat/data/hackneyed/svg/progress-6.svg +281 -0
- monocoat/data/hackneyed/svg/progress-7.svg +327 -0
- monocoat/data/hackneyed/svg/progress-8.svg +327 -0
- monocoat/data/hackneyed/svg/progress-9.svg +327 -0
- monocoat/data/hackneyed/svg/right_ptr.svg +256 -0
- monocoat/data/hackneyed/svg/right_tee.svg +226 -0
- monocoat/data/hackneyed/svg/s-resize.svg +226 -0
- monocoat/data/hackneyed/svg/sb_down_arrow.svg +237 -0
- monocoat/data/hackneyed/svg/sb_left_arrow.svg +237 -0
- monocoat/data/hackneyed/svg/sb_right_arrow.svg +237 -0
- monocoat/data/hackneyed/svg/sb_up_arrow.svg +196 -0
- monocoat/data/hackneyed/svg/se-resize.svg +206 -0
- monocoat/data/hackneyed/svg/split_h.svg +237 -0
- monocoat/data/hackneyed/svg/split_v.svg +230 -0
- monocoat/data/hackneyed/svg/sw-resize.svg +207 -0
- monocoat/data/hackneyed/svg/text.svg +231 -0
- monocoat/data/hackneyed/svg/top_tee.svg +226 -0
- monocoat/data/hackneyed/svg/ul_angle.svg +226 -0
- monocoat/data/hackneyed/svg/ur_angle.svg +226 -0
- monocoat/data/hackneyed/svg/vertical-text.svg +229 -0
- monocoat/data/hackneyed/svg/w-resize.svg +226 -0
- monocoat/data/hackneyed/svg/wait-1.svg +289 -0
- monocoat/data/hackneyed/svg/wait-10.svg +288 -0
- monocoat/data/hackneyed/svg/wait-11.svg +288 -0
- monocoat/data/hackneyed/svg/wait-12.svg +288 -0
- monocoat/data/hackneyed/svg/wait-13.svg +288 -0
- monocoat/data/hackneyed/svg/wait-14.svg +288 -0
- monocoat/data/hackneyed/svg/wait-15.svg +288 -0
- monocoat/data/hackneyed/svg/wait-16.svg +368 -0
- monocoat/data/hackneyed/svg/wait-2.svg +288 -0
- monocoat/data/hackneyed/svg/wait-3.svg +288 -0
- monocoat/data/hackneyed/svg/wait-4.svg +288 -0
- monocoat/data/hackneyed/svg/wait-5.svg +287 -0
- monocoat/data/hackneyed/svg/wait-6.svg +288 -0
- monocoat/data/hackneyed/svg/wait-7.svg +288 -0
- monocoat/data/hackneyed/svg/wait-8.svg +288 -0
- monocoat/data/hackneyed/svg/wait-9.svg +288 -0
- monocoat/data/hackneyed/svg/wayland-cursor.svg +244 -0
- monocoat/data/hackneyed/svg/zoom-in.svg +272 -0
- monocoat/data/hackneyed/svg/zoom-out.svg +273 -0
- monocoat/data/hackneyed/svg/zoom.svg +267 -0
- monocoat/data/hackneyed/symlinks +46 -0
- monocoat/data/monocoat-bar-ink.glsl +47 -0
- monocoat/data/monocoat-glass.glsl +106 -0
- monocoat/data/monocoat-liquid-glass.glsl +110 -0
- monocoat/data/monocoat-seamless.glsl +268 -0
- monocoat/data/unihan/LICENSE +39 -0
- monocoat/data/unihan/han-readings.txt +714 -0
- monocoat/daynight.py +115 -0
- monocoat/diff.py +271 -0
- monocoat/dockapps.py +542 -0
- monocoat/dockcatalog.py +137 -0
- monocoat/dockclasses.py +35 -0
- monocoat/dockconfig.py +1261 -0
- monocoat/dockd.py +473 -0
- monocoat/dockdraw.py +661 -0
- monocoat/dockfolder.py +640 -0
- monocoat/dockfoldergtk.py +1363 -0
- monocoat/dockgtk.py +5746 -0
- monocoat/dockhotcorners.py +811 -0
- monocoat/dockipc.py +114 -0
- monocoat/dockitems.py +550 -0
- monocoat/dockitemsgtk.py +58 -0
- monocoat/docklauncher.py +204 -0
- monocoat/docklaunchhelper.py +43 -0
- monocoat/docklaunchpadgtk.py +1520 -0
- monocoat/docklock.py +108 -0
- monocoat/dockmedia.py +746 -0
- monocoat/dockmediaart.py +442 -0
- monocoat/dockmediagtk.py +369 -0
- monocoat/dockminimizegtk.py +1496 -0
- monocoat/dockminimizex11.py +185 -0
- monocoat/dockmsgtips.py +589 -0
- monocoat/dockpinfile.py +285 -0
- monocoat/dockpins.py +980 -0
- monocoat/dockpreview.py +129 -0
- monocoat/dockpreviewgtk.py +2035 -0
- monocoat/dockpreviewlock.py +188 -0
- monocoat/dockpreviewx11.py +372 -0
- monocoat/dockscroll.py +125 -0
- monocoat/docktrack.py +429 -0
- monocoat/dockx11.py +842 -0
- monocoat/dockxwatch.py +79 -0
- monocoat/doctor.py +1986 -0
- monocoat/editor.py +47 -0
- monocoat/edittarget.py +151 -0
- monocoat/exit_codes.py +17 -0
- monocoat/fileio.py +46 -0
- monocoat/firefox.py +637 -0
- monocoat/follow.py +127 -0
- monocoat/frame.py +159 -0
- monocoat/fsbirth.py +53 -0
- monocoat/glass.py +586 -0
- monocoat/gtk3theme.py +125 -0
- monocoat/gui/__init__.py +45 -0
- monocoat/gui/app.py +56 -0
- monocoat/gui/apps.py +440 -0
- monocoat/gui/captions.py +227 -0
- monocoat/gui/colorpicker.py +203 -0
- monocoat/gui/controls.py +394 -0
- monocoat/gui/engine.py +435 -0
- monocoat/gui/firstrun.py +169 -0
- monocoat/gui/fontpicker.py +130 -0
- monocoat/gui/history.py +214 -0
- monocoat/gui/looks.py +411 -0
- monocoat/gui/m_backups.py +452 -0
- monocoat/gui/m_colourmatch.py +215 -0
- monocoat/gui/m_dock.py +916 -0
- monocoat/gui/m_firstrun.py +237 -0
- monocoat/gui/m_glass.py +630 -0
- monocoat/gui/m_health.py +655 -0
- monocoat/gui/m_notify.py +242 -0
- monocoat/gui/m_pointer.py +299 -0
- monocoat/gui/m_update.py +60 -0
- monocoat/gui/m_wallpaper.py +517 -0
- monocoat/gui/m_winstate.py +74 -0
- monocoat/gui/minidesktop.py +188 -0
- monocoat/gui/model.py +589 -0
- monocoat/gui/page_apps.py +568 -0
- monocoat/gui/page_backups.py +407 -0
- monocoat/gui/page_colours.py +666 -0
- monocoat/gui/page_dock.py +950 -0
- monocoat/gui/page_fonts.py +259 -0
- monocoat/gui/page_glass.py +371 -0
- monocoat/gui/page_health.py +580 -0
- monocoat/gui/page_notify.py +322 -0
- monocoat/gui/page_pointer.py +584 -0
- monocoat/gui/page_presets.py +762 -0
- monocoat/gui/page_wallpaper.py +491 -0
- monocoat/gui/pages.py +222 -0
- monocoat/gui/scheduler.py +205 -0
- monocoat/gui/widgets.py +914 -0
- monocoat/gui/window.py +1722 -0
- monocoat/iconthemes.py +296 -0
- monocoat/immersive.py +570 -0
- monocoat/inherit.py +93 -0
- monocoat/kittyconf.py +151 -0
- monocoat/lastwrites.py +254 -0
- monocoat/launcherindex.py +366 -0
- monocoat/layers/__init__.py +72 -0
- monocoat/layers/bundle.py +161 -0
- monocoat/layers/cursor.py +233 -0
- monocoat/layers/deep_recolor.py +1672 -0
- monocoat/layers/dock.py +106 -0
- monocoat/layers/dockd.py +69 -0
- monocoat/layers/effects.py +1598 -0
- monocoat/layers/fonts.py +629 -0
- monocoat/layers/gtk.py +230 -0
- monocoat/layers/launcher.py +241 -0
- monocoat/layers/libadwaita.py +148 -0
- monocoat/layers/notifications.py +88 -0
- monocoat/layers/palette.py +1206 -0
- monocoat/layers/panel.py +88 -0
- monocoat/layers/portal.py +272 -0
- monocoat/layers/qt.py +343 -0
- monocoat/layers/remote.py +169 -0
- monocoat/layers/settings_broadcast.py +103 -0
- monocoat/layers/wallpaper.py +438 -0
- monocoat/layers/window_manager.py +78 -0
- monocoat/liquidglass.py +578 -0
- monocoat/locks.py +230 -0
- monocoat/lockscreen.py +500 -0
- monocoat/lookgc.py +198 -0
- monocoat/manifest.py +568 -0
- monocoat/notifydnd.py +47 -0
- monocoat/out.py +125 -0
- monocoat/paths.py +228 -0
- monocoat/perfeffects.py +112 -0
- monocoat/perfprobe.py +304 -0
- monocoat/perftier.py +247 -0
- monocoat/picom.py +1424 -0
- monocoat/plank.py +125 -0
- monocoat/polybarlive.py +110 -0
- monocoat/presetedit.py +423 -0
- monocoat/presets.py +260 -0
- monocoat/procs.py +190 -0
- monocoat/registry.py +313 -0
- monocoat/reloaddebt.py +106 -0
- monocoat/remote_display.py +100 -0
- monocoat/remotesession.py +281 -0
- monocoat/rendercache.py +133 -0
- monocoat/schema.py +1878 -0
- monocoat/schema_doc.py +817 -0
- monocoat/scheme.py +197 -0
- monocoat/scssgen.py +138 -0
- monocoat/seamless.py +146 -0
- monocoat/selfcli.py +29 -0
- monocoat/session/__init__.py +340 -0
- monocoat/session/backends/__init__.py +3 -0
- monocoat/session/backends/keys.py +41 -0
- monocoat/session/backends/notify_dunst.py +126 -0
- monocoat/session/backends/notify_fdo.py +76 -0
- monocoat/session/backends/notify_gnome.py +24 -0
- monocoat/session/backends/notify_mako.py +88 -0
- monocoat/session/backends/notify_none.py +29 -0
- monocoat/session/backends/notify_plasma.py +63 -0
- monocoat/session/backends/notify_xfce.py +38 -0
- monocoat/session/backends/protocols.py +43 -0
- monocoat/session/backends/settings_gsettings.py +39 -0
- monocoat/session/backends/settings_kdeglobals.py +399 -0
- monocoat/session/backends/settings_xfconf.py +92 -0
- monocoat/session/backends/settings_xsettingsd.py +158 -0
- monocoat/session/backends/wm_kwin.py +105 -0
- monocoat/session/backends/wm_none.py +24 -0
- monocoat/session/backends/wm_xfwm4.py +50 -0
- monocoat/session/detect.py +445 -0
- monocoat/strikes.py +139 -0
- monocoat/style.py +884 -0
- monocoat/surfaces/__init__.py +6 -0
- monocoat/surfaces/adaptive.py +648 -0
- monocoat/surfaces/appcolors.py +200 -0
- monocoat/surfaces/appkind.py +281 -0
- monocoat/surfaces/backuparchive.py +163 -0
- monocoat/surfaces/bindings.py +125 -0
- monocoat/surfaces/buttonlayout.py +60 -0
- monocoat/surfaces/cssgen.py +75 -0
- monocoat/surfaces/csspin.py +245 -0
- monocoat/surfaces/cursorgen.py +178 -0
- monocoat/surfaces/desktopfile.py +157 -0
- monocoat/surfaces/dockbadge.py +178 -0
- monocoat/surfaces/dockedge.py +192 -0
- monocoat/surfaces/dockmath.py +842 -0
- monocoat/surfaces/dockminimize.py +605 -0
- monocoat/surfaces/dockmsg.py +331 -0
- monocoat/surfaces/dockpin.py +84 -0
- monocoat/surfaces/dockpreview.py +158 -0
- monocoat/surfaces/dockvisibility.py +113 -0
- monocoat/surfaces/dockwin.py +378 -0
- monocoat/surfaces/firefoxprefs.py +69 -0
- monocoat/surfaces/framegovernor.py +133 -0
- monocoat/surfaces/geometry.py +524 -0
- monocoat/surfaces/glassshape.py +60 -0
- monocoat/surfaces/hotcorners.py +252 -0
- monocoat/surfaces/inibind.py +70 -0
- monocoat/surfaces/kvantumgeom.py +366 -0
- monocoat/surfaces/launchpad.py +611 -0
- monocoat/surfaces/mydockfinder.py +1584 -0
- monocoat/surfaces/palettemath.py +284 -0
- monocoat/surfaces/perfbudget.py +196 -0
- monocoat/surfaces/pngcodec.py +186 -0
- monocoat/surfaces/polybarini.py +75 -0
- monocoat/surfaces/randr.py +167 -0
- monocoat/surfaces/remap.py +62 -0
- monocoat/surfaces/rofigrid.py +171 -0
- monocoat/surfaces/terminals.py +126 -0
- monocoat/surfaces/tomlarray.py +721 -0
- monocoat/surfaces/translit.py +158 -0
- monocoat/surfaces/usercss.py +268 -0
- monocoat/surfaces/xcursor.py +191 -0
- monocoat/tilemark.py +750 -0
- monocoat/tomlout.py +53 -0
- monocoat/trayprobe.py +162 -0
- monocoat/updater.py +815 -0
- monocoat/verify.py +421 -0
- monocoat/wallpaper_palette.py +259 -0
- monocoat/wallpaper_pipeline.py +940 -0
- monocoat/watcher.py +1412 -0
- monocoat/x11probe.py +596 -0
- monocoat/xroot.py +112 -0
- monocoat-1.2.0.dist-info/METADATA +386 -0
- monocoat-1.2.0.dist-info/RECORD +416 -0
- monocoat-1.2.0.dist-info/WHEEL +4 -0
- monocoat-1.2.0.dist-info/entry_points.txt +2 -0
- monocoat-1.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"""Pure color math: hex parse/validate, luminance, WCAG contrast, lighten/
|
|
2
|
+
darken, derive-missing-token, and the user-GTK-CSS derived tokens. No I/O, no
|
|
3
|
+
package imports.
|
|
4
|
+
|
|
5
|
+
Used by cssgen (fill libadwaita colors absent from [palette]) and reusable by
|
|
6
|
+
any future palette-driven generator (Kvantum SVG, terminals). The derived
|
|
7
|
+
tokens (`gtk_css_derived`) feed the palette layer's `palette/gtk-css` part (as
|
|
8
|
+
the fallback derivation — a preset's own `borders`/`unfocused_borders` tokens
|
|
9
|
+
win) and doctor's `check_hex`."""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import math
|
|
14
|
+
import re
|
|
15
|
+
|
|
16
|
+
_HEX_RE = re.compile(r"^#?(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$")
|
|
17
|
+
|
|
18
|
+
RGB = tuple[int, int, int]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def is_hex(value: str) -> bool:
|
|
22
|
+
"""True iff value is a 3- or 6-digit hex color (leading # optional)."""
|
|
23
|
+
return bool(isinstance(value, str) and _HEX_RE.match(value))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def parse_hex(value: str) -> RGB:
|
|
27
|
+
"""Parse "#rgb"/"#rrggbb"/"RRGGBB" → (r, g, b). Raises ValueError if invalid."""
|
|
28
|
+
if not is_hex(value):
|
|
29
|
+
raise ValueError(f"not a hex color: {value!r}")
|
|
30
|
+
s = value.lstrip("#")
|
|
31
|
+
if len(s) == 3:
|
|
32
|
+
s = "".join(c * 2 for c in s)
|
|
33
|
+
return int(s[0:2], 16), int(s[2:4], 16), int(s[4:6], 16)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def to_hex(rgb: RGB) -> str:
|
|
37
|
+
"""(r, g, b) → "#rrggbb" (always lowercase, always 6 digits)."""
|
|
38
|
+
r, g, b = (max(0, min(255, int(round(c)))) for c in rgb)
|
|
39
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _channel_lum(c: int) -> float:
|
|
43
|
+
cs = c / 255.0
|
|
44
|
+
return cs / 12.92 if cs <= 0.03928 else ((cs + 0.055) / 1.055) ** 2.4
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def luminance(rgb: RGB) -> float:
|
|
48
|
+
"""WCAG relative luminance (0.0 black .. 1.0 white)."""
|
|
49
|
+
r, g, b = rgb
|
|
50
|
+
return 0.2126 * _channel_lum(r) + 0.7152 * _channel_lum(g) + 0.0722 * _channel_lum(b)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def contrast_ratio(a: str, b: str) -> float:
|
|
54
|
+
"""WCAG contrast ratio between two hex colors (1.0 .. 21.0). Symmetric."""
|
|
55
|
+
la = luminance(parse_hex(a))
|
|
56
|
+
lb = luminance(parse_hex(b))
|
|
57
|
+
hi, lo = max(la, lb), min(la, lb)
|
|
58
|
+
return (hi + 0.05) / (lo + 0.05)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def scale_srgb(value: str, factor: float) -> str:
|
|
62
|
+
"""Multiply each sRGB channel by `factor` (0..1) and re-encode.
|
|
63
|
+
|
|
64
|
+
Models the CRT shader's `c.xyz *= scan` on stored 8-bit sRGB values at
|
|
65
|
+
the dimmest scanline row (`scan = 1 - sc_intensity`). The shader works on
|
|
66
|
+
the composited pixel, so foreground and background scale together; the
|
|
67
|
+
rounded 8-bit result is what the next compositor pass sees.
|
|
68
|
+
"""
|
|
69
|
+
r, g, b = parse_hex(value)
|
|
70
|
+
return to_hex((r * factor, g * factor, b * factor))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def contrast_ratio_scaled(a: str, b: str, factor: float) -> float:
|
|
74
|
+
"""WCAG contrast after scaling both colors by `factor` in sRGB.
|
|
75
|
+
|
|
76
|
+
The CRT shader dims alternating rows by the same per-channel factor.
|
|
77
|
+
WCAG luminance is nonlinear, so the ratio is not preserved; this returns
|
|
78
|
+
the dimmest-row (worst-case) ratio for opaque surfaces. `factor >= 1` is
|
|
79
|
+
the raw ratio. Glass over a bright backdrop can only be worse; that is
|
|
80
|
+
measured separately by `monocoat verify`, not modelled here.
|
|
81
|
+
"""
|
|
82
|
+
if factor >= 1.0:
|
|
83
|
+
return contrast_ratio(a, b)
|
|
84
|
+
f = max(0.0, factor)
|
|
85
|
+
return contrast_ratio(scale_srgb(a, f), scale_srgb(b, f))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def lighten(value: str, amount: float) -> str:
|
|
89
|
+
"""Move each channel `amount` (0..1) of the way toward white. Clamped."""
|
|
90
|
+
r, g, b = parse_hex(value)
|
|
91
|
+
return to_hex((r + (255 - r) * amount, g + (255 - g) * amount, b + (255 - b) * amount))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def darken(value: str, amount: float) -> str:
|
|
95
|
+
"""Move each channel `amount` (0..1) of the way toward black. Clamped."""
|
|
96
|
+
r, g, b = parse_hex(value)
|
|
97
|
+
return to_hex((r * (1 - amount), g * (1 - amount), b * (1 - amount)))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def derive_token(token: str, palette: dict) -> str | None:
|
|
101
|
+
"""Best-effort fill for a well-known palette token absent from `palette`.
|
|
102
|
+
|
|
103
|
+
Returns a hex string or None (caller leaves the token unset). Rules:
|
|
104
|
+
bg_alt → bg nudged 8% lighter (dark bg) or darker (light bg)
|
|
105
|
+
fg → primary, else a high-contrast bw vs bg
|
|
106
|
+
primary → fg
|
|
107
|
+
accent → primary
|
|
108
|
+
Only hex values already in `palette` are used as inputs."""
|
|
109
|
+
def hexval(name: str) -> str | None:
|
|
110
|
+
v = palette.get(name)
|
|
111
|
+
return v if isinstance(v, str) and is_hex(v) else None
|
|
112
|
+
|
|
113
|
+
if token == "bg_alt":
|
|
114
|
+
bg = hexval("bg")
|
|
115
|
+
if bg is None:
|
|
116
|
+
return None
|
|
117
|
+
return lighten(bg, 0.08) if luminance(parse_hex(bg)) < 0.5 else darken(bg, 0.08)
|
|
118
|
+
if token == "fg":
|
|
119
|
+
p = hexval("primary")
|
|
120
|
+
if p is not None:
|
|
121
|
+
return p
|
|
122
|
+
bg = hexval("bg")
|
|
123
|
+
if bg is not None:
|
|
124
|
+
return "#ffffff" if luminance(parse_hex(bg)) < 0.5 else "#000000"
|
|
125
|
+
return None
|
|
126
|
+
if token in ("primary",):
|
|
127
|
+
return hexval("fg")
|
|
128
|
+
if token == "accent":
|
|
129
|
+
return hexval("primary") or hexval("fg")
|
|
130
|
+
return None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# --- user GTK CSS derived tokens (2026-10-15 spec §2) ------------------------
|
|
134
|
+
|
|
135
|
+
# Fitted against the Reference gate (owner decision 3: the formula FAMILY).
|
|
136
|
+
# No single-stage formula family (sRGB or OKLab mix/lighten/darken, any
|
|
137
|
+
# token pair, any amount) reproduces the shipped shades #572c00 / #482400
|
|
138
|
+
# exactly — an exhaustive search found only two-stage fitted chains, hex
|
|
139
|
+
# pins in disguise, which the spec rejects. Owner ruling: Reference pins both
|
|
140
|
+
# shades as its own [palette] tokens (byte-exact), and THIS derivation
|
|
141
|
+
# serves presets without the tokens (generated presets derive the values
|
|
142
|
+
# here, at apply time). The glow rgba(primary, alpha) is exact.
|
|
143
|
+
GTK_CSS_BORDER_MIX = 0.24
|
|
144
|
+
GTK_CSS_UNFOCUSED_MIX = 0.28
|
|
145
|
+
GTK_CSS_GLOW_ALPHA = 0.35
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def mix(a: str, b: str, amount: float) -> str:
|
|
149
|
+
"""Move each channel `amount` (0..1) of the way from `a` toward `b`."""
|
|
150
|
+
ra, ga, ba = parse_hex(a)
|
|
151
|
+
rb, gb, bb = parse_hex(b)
|
|
152
|
+
return to_hex((ra + (rb - ra) * amount, ga + (gb - ga) * amount,
|
|
153
|
+
ba + (bb - ba) * amount))
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def gtk_css_derived(palette: dict) -> dict[str, str]:
|
|
157
|
+
"""Named derived tokens for the user GTK CSS: `borders`, `unfocused_borders`
|
|
158
|
+
(channel-wise mixes, fitted constants above) and `glow` (an `rgba(r, g, b,
|
|
159
|
+
<alpha>)` string following `primary` only). A token whose input palette
|
|
160
|
+
entry is missing or not a hex is left out — same rule as derive_token.
|
|
161
|
+
Never raises.
|
|
162
|
+
|
|
163
|
+
The DERIVATION, not the byte-gate: a preset may pin `borders` /
|
|
164
|
+
`unfocused_borders` as its own [palette] tokens (Reference does — the
|
|
165
|
+
shipped shades), and usercss prefers those; palettes without them get
|
|
166
|
+
these values."""
|
|
167
|
+
def hexval(name: str) -> str | None:
|
|
168
|
+
v = palette.get(name)
|
|
169
|
+
return v if isinstance(v, str) and is_hex(v) else None
|
|
170
|
+
|
|
171
|
+
out: dict[str, str] = {}
|
|
172
|
+
bg_alt, accent = hexval("bg_alt"), hexval("accent")
|
|
173
|
+
if bg_alt is not None and accent is not None:
|
|
174
|
+
out["borders"] = mix(bg_alt, accent, GTK_CSS_BORDER_MIX)
|
|
175
|
+
out["unfocused_borders"] = mix(out["borders"], bg_alt, GTK_CSS_UNFOCUSED_MIX)
|
|
176
|
+
primary = hexval("primary")
|
|
177
|
+
if primary is not None:
|
|
178
|
+
r, g, b = parse_hex(primary)
|
|
179
|
+
out["glow"] = f"rgba({r}, {g}, {b}, {GTK_CSS_GLOW_ALPHA})"
|
|
180
|
+
return out
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# --- OKLab / OKLCH (Björn Ottosson's matrices) ---------------------------------
|
|
184
|
+
|
|
185
|
+
def _to_linear(c: int) -> float:
|
|
186
|
+
s = c / 255
|
|
187
|
+
return s / 12.92 if s <= 0.04045 else ((s + 0.055) / 1.055) ** 2.4
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _from_linear(x: float) -> float:
|
|
191
|
+
s = 12.92 * x if x <= 0.0031308 else 1.055 * x ** (1 / 2.4) - 0.055
|
|
192
|
+
return s * 255
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _oklab(value: str) -> tuple[float, float, float]:
|
|
196
|
+
r, g, b = (_to_linear(c) for c in parse_hex(value))
|
|
197
|
+
lc = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b
|
|
198
|
+
mc = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b
|
|
199
|
+
sc = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b
|
|
200
|
+
lc, mc, sc = (x ** (1 / 3) for x in (lc, mc, sc))
|
|
201
|
+
return (0.2104542553 * lc + 0.7936177850 * mc - 0.0040720468 * sc,
|
|
202
|
+
1.9779984951 * lc - 2.4285922050 * mc + 0.4505937099 * sc,
|
|
203
|
+
0.0259040371 * lc + 0.7827717662 * mc - 0.8086757660 * sc)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _rgb_from_oklab(L: float, a: float, b: float) -> tuple[float, float, float]:
|
|
207
|
+
lc = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3
|
|
208
|
+
mc = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3
|
|
209
|
+
sc = (L - 0.0894841775 * a - 1.2914855480 * b) ** 3
|
|
210
|
+
lin = (4.0767416621 * lc - 3.3077115913 * mc + 0.2309699292 * sc,
|
|
211
|
+
-1.2684380046 * lc + 2.6097574011 * mc - 0.3413193965 * sc,
|
|
212
|
+
-0.0041960863 * lc - 0.7034186147 * mc + 1.7076147010 * sc)
|
|
213
|
+
return tuple(_from_linear(max(x, 0.0)) if x >= 0 else -1.0 for x in lin)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def mix_oklab(a: str, b: str, amount: float) -> str:
|
|
217
|
+
"""Move `amount` (0..1) of the way from `a` toward `b` in OKLab; channels
|
|
218
|
+
that leave the sRGB gamut are clamped."""
|
|
219
|
+
la, lb = _oklab(a), _oklab(b)
|
|
220
|
+
lab = tuple(x + (y - x) * amount for x, y in zip(la, lb, strict=True))
|
|
221
|
+
lc, mc, sc = (max(0.0, x) for x in (
|
|
222
|
+
(lab[0] + 0.3963377774 * lab[1] + 0.2158037573 * lab[2]) ** 3,
|
|
223
|
+
(lab[0] - 0.1055613458 * lab[1] - 0.0638541728 * lab[2]) ** 3,
|
|
224
|
+
(lab[0] - 0.0894841775 * lab[1] - 1.2914855480 * lab[2]) ** 3))
|
|
225
|
+
lin = (4.0767416621 * lc - 3.3077115913 * mc + 0.2309699292 * sc,
|
|
226
|
+
-1.2684380046 * lc + 2.6097574011 * mc - 0.3413193965 * sc,
|
|
227
|
+
-0.0041960863 * lc - 0.7034186147 * mc + 1.7076147010 * sc)
|
|
228
|
+
return to_hex(tuple(_from_linear(min(1.0, max(0.0, x))) for x in lin))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def to_oklch(value: str) -> tuple[float, float, float]:
|
|
232
|
+
L, a, b = _oklab(value)
|
|
233
|
+
return L, math.hypot(a, b), math.degrees(math.atan2(b, a)) % 360
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def _in_gamut(L: float, C: float, h: float) -> tuple[float, float, float] | None:
|
|
237
|
+
rad = math.radians(h)
|
|
238
|
+
rgb = _rgb_from_oklab(L, C * math.cos(rad), C * math.sin(rad))
|
|
239
|
+
return rgb if all(-0.5 <= x <= 255.5 for x in rgb) else None
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def oklch_hex(L: float, C: float, h: float) -> str:
|
|
243
|
+
"""The sRGB color at (L, C, h), chroma reduced until it fits the gamut."""
|
|
244
|
+
L = min(max(L, 0.0), 1.0)
|
|
245
|
+
rgb = _in_gamut(L, C, h)
|
|
246
|
+
if rgb is None:
|
|
247
|
+
lo, hi = 0.0, C
|
|
248
|
+
for _ in range(30):
|
|
249
|
+
mid = (lo + hi) / 2
|
|
250
|
+
lo, hi = (mid, hi) if _in_gamut(L, mid, h) else (lo, mid)
|
|
251
|
+
rgb = _in_gamut(L, lo, h)
|
|
252
|
+
return to_hex(tuple(min(255, max(0, round(x))) for x in rgb)).upper()
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def max_chroma(L: float, h: float) -> float:
|
|
256
|
+
"""The sRGB gamut's chroma ceiling at (L, h) — the same clamp binary
|
|
257
|
+
search oklch_hex uses, run to a fixed high bound instead of a requested C."""
|
|
258
|
+
L = min(max(L, 0.0), 1.0)
|
|
259
|
+
lo, hi = 0.0, 0.6
|
|
260
|
+
if _in_gamut(L, hi, h):
|
|
261
|
+
return hi
|
|
262
|
+
for _ in range(30):
|
|
263
|
+
mid = (lo + hi) / 2
|
|
264
|
+
lo, hi = (mid, hi) if _in_gamut(L, mid, h) else (lo, mid)
|
|
265
|
+
return lo
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def delta_e(a: str, b: str) -> float:
|
|
269
|
+
return math.dist(_oklab(a), _oklab(b))
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def solve_lightness(hue: float, chroma: float, against: str, target: float) -> str | None:
|
|
273
|
+
"""Lowest-L color at (hue, chroma) whose contrast with `against` reaches
|
|
274
|
+
`target`, searching up from `against`'s lightness; None if white-most fails."""
|
|
275
|
+
lo, hi = to_oklch(against)[0], 1.0
|
|
276
|
+
if contrast_ratio(oklch_hex(hi, chroma, hue), against) < target:
|
|
277
|
+
return None
|
|
278
|
+
for _ in range(40):
|
|
279
|
+
mid = (lo + hi) / 2
|
|
280
|
+
if contrast_ratio(oklch_hex(mid, chroma, hue), against) >= target:
|
|
281
|
+
hi = mid
|
|
282
|
+
else:
|
|
283
|
+
lo = mid
|
|
284
|
+
return oklch_hex(hi, chroma, hue)
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""Performance tiers and the budget each one sets (pure; no I/O).
|
|
2
|
+
|
|
3
|
+
``monocoat perf`` measures a machine (:mod:`monocoat.perfprobe`) and this
|
|
4
|
+
module turns the measurements into one of three tiers, with the reasons, and
|
|
5
|
+
each tier into a :class:`Budget`: the concrete knobs the animated surfaces
|
|
6
|
+
read (docs/superpowers/specs/2026-10-27-adaptive-performance-design.md §2.B).
|
|
7
|
+
A tier never changes how a look appears at rest, only how much work its
|
|
8
|
+
animations may cost.
|
|
9
|
+
|
|
10
|
+
Measured 2026-10-27 on the laptop (UHD 620, 60 Hz): window animations ran
|
|
11
|
+
60-100 % busy at the i915 300 MHz floor and every window map stalled the X
|
|
12
|
+
server 25-45 ms; those are the two signals :func:`classify` reads.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import asdict, dataclass
|
|
18
|
+
|
|
19
|
+
FULL = "full"
|
|
20
|
+
BALANCED = "balanced"
|
|
21
|
+
LIGHT = "light"
|
|
22
|
+
TIERS = (FULL, BALANCED, LIGHT)
|
|
23
|
+
|
|
24
|
+
# A stall longer than this many frame periods drops visible frames.
|
|
25
|
+
STALL_FRAMES_LIGHT = 2.0
|
|
26
|
+
STALL_FRAMES_FULL = 1.0
|
|
27
|
+
# Mean GPU busy share during the load phase.
|
|
28
|
+
BUSY_LIGHT = 0.8
|
|
29
|
+
BUSY_FULL = 0.5
|
|
30
|
+
# The GPU never left its floor clock while busier than this: the driver's
|
|
31
|
+
# frequency ramp is slower than the animations.
|
|
32
|
+
STARVED_BUSY = 0.5
|
|
33
|
+
# ...and its peak clock stayed below this share of the maximum.
|
|
34
|
+
STARVED_PEAK = 0.8
|
|
35
|
+
# An effect frame (monocoat's own drawing, measured off screen) costing more
|
|
36
|
+
# than this many frame periods drops frames on its own.
|
|
37
|
+
EFFECT_FRAMES_LIGHT = 2.0
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class Budget:
|
|
42
|
+
"""What one tier allows each animated surface."""
|
|
43
|
+
|
|
44
|
+
tier: str
|
|
45
|
+
immersive_fade_hz: float # bar cross-fade re-announce rate (0 = cut)
|
|
46
|
+
immersive_settle_s: float # bar resample cadence after a window event
|
|
47
|
+
minimize_effect: str # the genie as configured, or "scale" (cheaper)
|
|
48
|
+
dock_hide_animation: str # "slide" or "fade"
|
|
49
|
+
picom_geometry: bool # picom's size-change animation (moves never animate)
|
|
50
|
+
|
|
51
|
+
def as_dict(self) -> dict:
|
|
52
|
+
return asdict(self)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
BUDGETS = {
|
|
56
|
+
FULL: Budget(FULL, 60.0, 0.1, "genie", "slide", True),
|
|
57
|
+
BALANCED: Budget(BALANCED, 20.0, 0.25, "genie", "slide", True),
|
|
58
|
+
# Measured 2026-10-27 on the laptop's server: a genie frame 11.5 ms
|
|
59
|
+
# median (p90 ~30 ms), the scale effect 5 ms. The geometry animation
|
|
60
|
+
# was off here only because drags trailed the pointer; since the size
|
|
61
|
+
# gate (picom.reconcile_perf_rules) a drag is as fast as with it off
|
|
62
|
+
# and a maximize still animates (UHD 620, 2026-10-28).
|
|
63
|
+
LIGHT: Budget(LIGHT, 0.0, 0.5, "scale", "fade", True),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def budget(tier: str) -> Budget:
|
|
68
|
+
return BUDGETS[tier if tier in BUDGETS else BALANCED]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# One duration for every colour cross-fade a look switch starts: the dock's
|
|
72
|
+
# palette tween and the bar backdrop's strip cross-fade (owner decision D2,
|
|
73
|
+
# 2026-10-28; they were 220 ms and 500 ms). 300 ms is a standard "medium"
|
|
74
|
+
# UI transition: long enough to read as a fade, short enough to finish with
|
|
75
|
+
# the GTK and kitty snaps instead of trailing them.
|
|
76
|
+
FADE_MS = 300
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def colour_fade_ms(b: Budget) -> int:
|
|
80
|
+
"""FADE_MS, or 0 (a cut) where the budget cannot afford the bar's fade
|
|
81
|
+
frames (immersive_fade_hz 0, the light tier): every surface fades or
|
|
82
|
+
every surface cuts, never a mix."""
|
|
83
|
+
return FADE_MS if b.immersive_fade_hz > 0 else 0
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def colour_ease(t: float) -> float:
|
|
87
|
+
"""The curve every colour cross-fade follows (smoothstep, clamped).
|
|
88
|
+
|
|
89
|
+
The dock's palette tween and the bar's strip fade share it with FADE_MS,
|
|
90
|
+
so the two move in step. Its largest frame-to-frame step is 1.5x the
|
|
91
|
+
linear one (24 % over the balanced tier's six 20 Hz frames, where an
|
|
92
|
+
ease-in-out cubic jumps 35 % twice).
|
|
93
|
+
"""
|
|
94
|
+
t = max(0.0, min(1.0, t))
|
|
95
|
+
return t * t * (3.0 - 2.0 * t)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def colour_ease_out(t: float) -> float:
|
|
99
|
+
"""colour_ease's second half, stretched over [0, 1]: a fade retargeted
|
|
100
|
+
mid-flight leaves the colour on screen at the curve's peak speed (1.5x
|
|
101
|
+
linear) instead of from rest, and lands as softly."""
|
|
102
|
+
return 2.0 * colour_ease(0.5 + max(0.0, min(1.0, t)) / 2.0) - 1.0
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def gpu_default(gpu: dict) -> tuple[str, str]:
|
|
106
|
+
"""(tier, reason) from the GPU class alone, before any measurement."""
|
|
107
|
+
kind = gpu.get("kind")
|
|
108
|
+
if kind in ("nvidia", "amd"):
|
|
109
|
+
return FULL, f"{kind} GPU"
|
|
110
|
+
if kind == "intel":
|
|
111
|
+
return BALANCED, "Intel integrated GPU"
|
|
112
|
+
return BALANCED, "unknown GPU"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def percentile(values: list[float], share: float) -> float | None:
|
|
116
|
+
if not values:
|
|
117
|
+
return None
|
|
118
|
+
ordered = sorted(values)
|
|
119
|
+
return ordered[min(len(ordered) - 1, int(len(ordered) * share))]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def classify(gpu: dict, load: dict | None, refresh_hz: float | None,
|
|
123
|
+
effects: dict | None = None) -> tuple[str, list[str]]:
|
|
124
|
+
"""(tier, reasons) from the GPU, its effect costs and the load phase.
|
|
125
|
+
|
|
126
|
+
``load`` is :func:`monocoat.perfprobe.measure`'s summary of a load
|
|
127
|
+
phase: ``xstall_ms`` (round-trip samples), ``busy`` (GPU busy shares),
|
|
128
|
+
``mhz`` (actual clocks); ``None`` = nothing measured, the GPU class
|
|
129
|
+
decides. ``effects`` maps an effect name to its p90 frame cost in ms,
|
|
130
|
+
drawn off screen on this display (``None`` = could not run): any over
|
|
131
|
+
one frame period caps the tier at balanced, over two makes it light.
|
|
132
|
+
"""
|
|
133
|
+
if not load:
|
|
134
|
+
return _classify(gpu, None, None, refresh_hz, effects, measured=False)
|
|
135
|
+
busy = load.get("busy") or []
|
|
136
|
+
return _classify(gpu, percentile(load.get("xstall_ms") or [], 0.99),
|
|
137
|
+
sum(busy) / len(busy) if busy else None, refresh_hz, effects)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def reclassify(report: dict, refresh_hz: float) -> tuple[str, list[str]] | None:
|
|
141
|
+
"""(tier, reasons) for a saved ``monocoat perf`` report judged at
|
|
142
|
+
``refresh_hz`` instead of the rate it was measured at, from the summary
|
|
143
|
+
it keeps (the load's p99 round trip and mean GPU busy share are exactly
|
|
144
|
+
what :func:`classify` reads); None when the report lacks its GPU."""
|
|
145
|
+
gpu = report.get("gpu")
|
|
146
|
+
if not isinstance(gpu, dict):
|
|
147
|
+
return None
|
|
148
|
+
load = report.get("load")
|
|
149
|
+
effects = report.get("effects_ms_p90")
|
|
150
|
+
effects = effects if isinstance(effects, dict) else None
|
|
151
|
+
if not isinstance(load, dict):
|
|
152
|
+
return _classify(gpu, None, None, refresh_hz, effects, measured=False)
|
|
153
|
+
stall = (load.get("xstall_ms") or {}).get("p99")
|
|
154
|
+
busy = (load.get("gpu_busy") or {}).get("mean")
|
|
155
|
+
return _classify(gpu, stall, busy, refresh_hz, effects)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _classify(gpu: dict, stall: float | None, mean_busy: float | None,
|
|
159
|
+
refresh_hz: float | None, effects: dict | None, *,
|
|
160
|
+
measured: bool = True) -> tuple[str, list[str]]:
|
|
161
|
+
tier, reason = gpu_default(gpu)
|
|
162
|
+
reasons = [reason]
|
|
163
|
+
period = 1000.0 / (refresh_hz or 60.0)
|
|
164
|
+
slow = [f"{name} costs {ms:.0f} ms a frame (budget {period:.0f} ms)"
|
|
165
|
+
for name, ms in sorted((effects or {}).items())
|
|
166
|
+
if ms is not None and ms > period]
|
|
167
|
+
if any(ms is not None and ms > EFFECT_FRAMES_LIGHT * period
|
|
168
|
+
for ms in (effects or {}).values()):
|
|
169
|
+
return LIGHT, reasons + slow
|
|
170
|
+
if not measured:
|
|
171
|
+
return (BALANCED, reasons + slow) if slow and tier == FULL else (tier, reasons + slow)
|
|
172
|
+
heavy = []
|
|
173
|
+
if stall is not None and stall > STALL_FRAMES_LIGHT * period:
|
|
174
|
+
heavy.append(f"X server stalls up to {stall:.0f} ms (p99) while windows animate")
|
|
175
|
+
if mean_busy is not None and mean_busy > BUSY_LIGHT:
|
|
176
|
+
heavy.append(f"GPU {mean_busy:.0%} busy while windows animate")
|
|
177
|
+
if heavy:
|
|
178
|
+
return LIGHT, reasons + slow + heavy
|
|
179
|
+
calm = ((stall is None or stall <= STALL_FRAMES_FULL * period)
|
|
180
|
+
and (mean_busy is None or mean_busy <= BUSY_FULL))
|
|
181
|
+
if calm and not slow and (stall is not None or mean_busy is not None):
|
|
182
|
+
return FULL, reasons + ["animations fit the frame budget"]
|
|
183
|
+
return BALANCED, reasons + (slow or ["animations sometimes miss a frame"])
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def starved(gpu: dict, load: dict | None) -> bool:
|
|
187
|
+
"""The GPU was busy but its clock never came near its maximum (a
|
|
188
|
+
frequency ramp slower than the animations, which a higher floor fixes;
|
|
189
|
+
see the laptop's TLP drop-in). A single sample's clock reads the floor
|
|
190
|
+
while the GPU power-gates, so only the peak clock is evidence."""
|
|
191
|
+
if not load or not gpu.get("max_mhz"):
|
|
192
|
+
return False
|
|
193
|
+
busy, mhz = load.get("busy") or [], load.get("mhz") or []
|
|
194
|
+
if not mhz or not any(share > STARVED_BUSY for share in busy):
|
|
195
|
+
return False
|
|
196
|
+
return max(mhz) < STARVED_PEAK * gpu["max_mhz"]
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Stdlib-only PNG codec for the measured raster envelope (audit r-c2).
|
|
2
|
+
|
|
3
|
+
Pure — no I/O, no package imports (surfaces rule). Decodes colour types
|
|
4
|
+
0/2/3/4/6 at bit depth 8, filters 0–4, non-interlaced, into RGBA8 rows;
|
|
5
|
+
encodes deterministically (filter 0, zlib level 9, IHDR/IDAT/IEND only).
|
|
6
|
+
Anything outside the envelope raises PngError — a file is refused, never
|
|
7
|
+
corrupted.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import struct
|
|
12
|
+
import zlib
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PngError(ValueError):
|
|
17
|
+
"""The PNG is outside the supported envelope or corrupt."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class Image:
|
|
22
|
+
width: int
|
|
23
|
+
height: int
|
|
24
|
+
rows: list[bytes] # RGBA8, each row width*4 bytes
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
_SIGNATURE = b"\x89PNG\r\n\x1a\n"
|
|
28
|
+
_BPP = {0: 1, 2: 3, 3: 1, 4: 2, 6: 4}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _chunk(typ: bytes, data: bytes) -> bytes:
|
|
32
|
+
return (struct.pack(">I", len(data)) + typ + data
|
|
33
|
+
+ struct.pack(">I", zlib.crc32(typ + data)))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _paeth(a: int, b: int, c: int) -> int:
|
|
37
|
+
p = a + b - c
|
|
38
|
+
pa, pb, pc = abs(p - a), abs(p - b), abs(p - c)
|
|
39
|
+
return a if pa <= pb and pa <= pc else (b if pb <= pc else c)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _unfilter(raw: bytes, width: int, bpp: int) -> list[bytes]:
|
|
43
|
+
"""Remove per-scanline filters (types 0–4) from the decompressed IDAT."""
|
|
44
|
+
stride = width * bpp
|
|
45
|
+
out: list[bytes] = []
|
|
46
|
+
prev = bytes(stride)
|
|
47
|
+
pos = 0
|
|
48
|
+
for _ in range(len(raw) // (stride + 1)):
|
|
49
|
+
f, line = raw[pos], bytearray(raw[pos + 1:pos + 1 + stride])
|
|
50
|
+
pos += stride + 1
|
|
51
|
+
if f == 1:
|
|
52
|
+
for i in range(bpp, stride):
|
|
53
|
+
line[i] = (line[i] + line[i - bpp]) & 0xFF
|
|
54
|
+
elif f == 2:
|
|
55
|
+
for i in range(stride):
|
|
56
|
+
line[i] = (line[i] + prev[i]) & 0xFF
|
|
57
|
+
elif f == 3:
|
|
58
|
+
for i in range(stride):
|
|
59
|
+
line[i] = (line[i] + ((prev[i] + (line[i - bpp] if i >= bpp else 0)) // 2)) & 0xFF
|
|
60
|
+
elif f == 4:
|
|
61
|
+
for i in range(stride):
|
|
62
|
+
left = line[i - bpp] if i >= bpp else 0
|
|
63
|
+
upper_left = prev[i - bpp] if i >= bpp else 0
|
|
64
|
+
line[i] = (line[i] + _paeth(left, prev[i], upper_left)) & 0xFF
|
|
65
|
+
elif f != 0:
|
|
66
|
+
raise PngError(f"unsupported filter {f}")
|
|
67
|
+
prev = bytes(line)
|
|
68
|
+
out.append(prev)
|
|
69
|
+
return out
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _to_rgba(samples: list[bytes], width: int, ct: int, plte: bytes) -> list[bytes]:
|
|
73
|
+
if ct == 6:
|
|
74
|
+
return samples # already immutable RGBA8 rows; no per-pixel conversion
|
|
75
|
+
bpp = _BPP[ct]
|
|
76
|
+
rows: list[bytes] = []
|
|
77
|
+
for line in samples:
|
|
78
|
+
row = bytearray(width * 4)
|
|
79
|
+
if ct in (0, 2, 4):
|
|
80
|
+
# Extended slices copy channels in C while keeping the decoded
|
|
81
|
+
# bytes exactly the same as the scalar palette path below.
|
|
82
|
+
if ct == 2:
|
|
83
|
+
row[0::4], row[1::4], row[2::4] = line[0::3], line[1::3], line[2::3]
|
|
84
|
+
else:
|
|
85
|
+
gray = line[::bpp]
|
|
86
|
+
row[0::4] = row[1::4] = row[2::4] = gray
|
|
87
|
+
row[3::4] = line[1::2] if ct == 4 else b"\xff" * width
|
|
88
|
+
rows.append(bytes(row))
|
|
89
|
+
continue
|
|
90
|
+
for i in range(width):
|
|
91
|
+
v = line[i * bpp:i * bpp + bpp]
|
|
92
|
+
if ct == 0:
|
|
93
|
+
r = g = b = v[0]
|
|
94
|
+
a = 255
|
|
95
|
+
elif ct == 2:
|
|
96
|
+
r, g, b, a = v[0], v[1], v[2], 255
|
|
97
|
+
elif ct == 3:
|
|
98
|
+
idx = v[0]
|
|
99
|
+
if (idx + 1) * 3 > len(plte):
|
|
100
|
+
raise PngError("corrupt PNG: palette index out of range")
|
|
101
|
+
r, g, b = plte[idx * 3], plte[idx * 3 + 1], plte[idx * 3 + 2]
|
|
102
|
+
a = 255
|
|
103
|
+
elif ct == 4:
|
|
104
|
+
r = g = b = v[0]
|
|
105
|
+
a = v[1]
|
|
106
|
+
else:
|
|
107
|
+
r, g, b, a = v
|
|
108
|
+
row[i * 4:i * 4 + 4] = bytes((r, g, b, a))
|
|
109
|
+
rows.append(bytes(row))
|
|
110
|
+
return rows
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def decode(data: bytes) -> Image:
|
|
114
|
+
if not data.startswith(_SIGNATURE):
|
|
115
|
+
raise PngError("not a PNG signature")
|
|
116
|
+
pos = len(_SIGNATURE)
|
|
117
|
+
ihdr: tuple | None = None
|
|
118
|
+
plte = b""
|
|
119
|
+
idat = bytearray()
|
|
120
|
+
while pos < len(data):
|
|
121
|
+
if pos + 12 > len(data):
|
|
122
|
+
raise PngError("corrupt PNG: truncated chunk")
|
|
123
|
+
(size,) = struct.unpack(">I", data[pos:pos + 4])
|
|
124
|
+
typ = data[pos + 4:pos + 8]
|
|
125
|
+
if pos + 12 + size > len(data):
|
|
126
|
+
raise PngError("corrupt PNG: truncated chunk")
|
|
127
|
+
payload = data[pos + 8:pos + 8 + size]
|
|
128
|
+
if zlib.crc32(typ + payload) != struct.unpack(">I", data[pos + 8 + size:pos + 12 + size])[0]:
|
|
129
|
+
raise PngError(f"bad CRC in {typ.decode(errors='replace')}")
|
|
130
|
+
pos += 12 + size
|
|
131
|
+
if typ == b"IHDR":
|
|
132
|
+
if ihdr is not None:
|
|
133
|
+
raise PngError("duplicate IHDR")
|
|
134
|
+
if len(payload) != 13:
|
|
135
|
+
raise PngError("corrupt PNG: bad IHDR length")
|
|
136
|
+
ihdr = struct.unpack(">IIBBBBB", payload)
|
|
137
|
+
elif typ == b"PLTE":
|
|
138
|
+
plte = payload
|
|
139
|
+
elif typ == b"IDAT":
|
|
140
|
+
idat += payload
|
|
141
|
+
elif typ == b"IEND":
|
|
142
|
+
break
|
|
143
|
+
elif typ == b"tRNS":
|
|
144
|
+
# Outside the measured envelope: skipping it (the lowercase-ancillary
|
|
145
|
+
# branch) would silently drop a palette PNG's transparency.
|
|
146
|
+
raise PngError("unsupported tRNS")
|
|
147
|
+
elif typ[:1].islower():
|
|
148
|
+
continue # ancillary (gAMA, pHYs, …): dropped on encode
|
|
149
|
+
else:
|
|
150
|
+
raise PngError(f"unsupported chunk {typ.decode(errors='replace')!r}")
|
|
151
|
+
if ihdr is None:
|
|
152
|
+
raise PngError("missing IHDR")
|
|
153
|
+
width, height, depth, ct, comp, filt, interlace = ihdr
|
|
154
|
+
if depth != 8:
|
|
155
|
+
raise PngError(f"unsupported bit depth {depth}")
|
|
156
|
+
if ct not in _BPP:
|
|
157
|
+
raise PngError(f"unsupported colour type {ct}")
|
|
158
|
+
if comp != 0 or filt != 0:
|
|
159
|
+
raise PngError("unsupported compression/filter method")
|
|
160
|
+
if interlace != 0:
|
|
161
|
+
raise PngError(f"unsupported interlace {interlace}")
|
|
162
|
+
if ct == 3 and not plte:
|
|
163
|
+
raise PngError("palette PNG without PLTE")
|
|
164
|
+
if plte and len(plte) % 3:
|
|
165
|
+
raise PngError("corrupt PNG: bad PLTE length")
|
|
166
|
+
try:
|
|
167
|
+
raw = zlib.decompress(bytes(idat))
|
|
168
|
+
except zlib.error as e:
|
|
169
|
+
raise PngError(f"corrupt IDAT: {e}") from e
|
|
170
|
+
samples = _unfilter(raw, width, _BPP[ct])
|
|
171
|
+
if len(samples) != height:
|
|
172
|
+
raise PngError("corrupt PNG: scanline count mismatch")
|
|
173
|
+
# The explicit bounds checks above (chunk truncation, IHDR length, PLTE
|
|
174
|
+
# length, the palette-index guard in _to_rgba) are what convert
|
|
175
|
+
# struct.error / IndexError into PngError; no blanket try/except is
|
|
176
|
+
# needed — and one would be wrong, since PngError IS a ValueError.
|
|
177
|
+
return Image(width, height, _to_rgba(samples, width, ct, plte))
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def encode(img: Image) -> bytes:
|
|
181
|
+
raw = b"".join(b"\x00" + row for row in img.rows) # filter 0 (None) per scanline
|
|
182
|
+
idat = zlib.compressobj(level=9, memLevel=9)
|
|
183
|
+
compressed = idat.compress(raw) + idat.flush()
|
|
184
|
+
ihdr = struct.pack(">IIBBBBB", img.width, img.height, 8, 6, 0, 0, 0)
|
|
185
|
+
return (_SIGNATURE + _chunk(b"IHDR", ihdr) + _chunk(b"IDAT", compressed)
|
|
186
|
+
+ _chunk(b"IEND", b""))
|