Documentation
¶
Overview ¶
Command darkmode adds the two things a page needs to respect a reader's colour preference: a theme-color meta per scheme, and a stylesheet link that only loads in dark mode.
darkmode -dark '#101014' -light '#ffffff' -stylesheet /dark.css page.html <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)"> <meta name="theme-color" content="#101014" media="(prefers-color-scheme: dark)"> <link rel="stylesheet" href="/dark.css" media="(prefers-color-scheme: dark)">
A page that already declares a media-qualified theme-color keeps it, because the page has thought about this and the flags have not. A bare theme-color with no media is a different case: it applies to both schemes, which is what this program exists to replace, so it is reported and left for the operator to remove rather than silently overridden.
The colours are checked before they go anywhere. A theme-color that a browser cannot parse is ignored, which looks identical to the meta being absent, so an unparseable one is refused rather than emitted.