bread-theme 0.2.7: luminance-picked ink + live reload
Readability: pywal can emit a light value in any palette slot, and the shared
sheet assumed dark backgrounds (white text), so text vanished on light surfaces/
accents. Add ink_on() — a WCAG-luminance pick of near-black/near-white per
background — exposed as @on-bg/@on-surface/@on-accent/@on-red/@on-overlay. The
component sheet now sets colour on containers and lets labels inherit (de-emphasis
via opacity), dropping the blanket `label { color }` rule that overrode
coloured-background text. pywal hues are untouched.
Hot reload: add gtk::apply_app_css(closure) — applies an app's own CSS now and
re-runs the closure whenever the shared theme file is rewritten, so apps recolour
in place. New `bread-theme reload` verb rewrites the file (atomic rename trips
every running GUI's monitor) — the command to run after changing pywal colours.
This commit is contained in:
parent
46db2c23cd
commit
0494650805
3 changed files with 167 additions and 42 deletions
|
|
@ -5,11 +5,26 @@
|
|||
//!
|
||||
//! bread-theme # same as `generate`
|
||||
//! bread-theme generate # render + write the shared stylesheet
|
||||
//! bread-theme reload # re-render from the current pywal palette and
|
||||
//! # signal every running bread GUI to recolour
|
||||
//! bread-theme path # print the stylesheet path
|
||||
//! bread-theme print # render to stdout (no write)
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn write_and_report(verb: &str) -> ExitCode {
|
||||
match bread_theme::write_shared_css() {
|
||||
Ok(path) => {
|
||||
eprintln!("bread-theme: {verb} {}", path.display());
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("bread-theme: failed to write stylesheet: {e}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let cmd = std::env::args().nth(1).unwrap_or_else(|| "generate".into());
|
||||
match cmd.as_str() {
|
||||
|
|
@ -21,21 +36,18 @@ fn main() -> ExitCode {
|
|||
print!("{}", bread_theme::render());
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
"generate" => match bread_theme::write_shared_css() {
|
||||
Ok(path) => {
|
||||
eprintln!("bread-theme: wrote {}", path.display());
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("bread-theme: failed to write stylesheet: {e}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
},
|
||||
"generate" => write_and_report("wrote"),
|
||||
// `reload` is `generate` from the caller's view, but it's the verb to use
|
||||
// after changing pywal colours: rewriting the file (atomic rename) trips
|
||||
// the file monitor in every running bread GUI, so they all re-read the
|
||||
// palette and recolour live — shared widgets *and* each app's own rules.
|
||||
"reload" => write_and_report("reloaded"),
|
||||
"-h" | "--help" | "help" => {
|
||||
eprintln!(
|
||||
"bread-theme — shared stylesheet generator\n\n\
|
||||
USAGE:\n bread-theme [generate|path|print]\n\n\
|
||||
USAGE:\n bread-theme [generate|reload|path|print]\n\n\
|
||||
generate render the pywal palette to the shared stylesheet (default)\n\
|
||||
reload re-render and signal running bread GUIs to recolour live\n\
|
||||
path print the stylesheet path ({})\n\
|
||||
print render to stdout without writing",
|
||||
bread_theme::shared_css_path().display()
|
||||
|
|
@ -43,7 +55,7 @@ fn main() -> ExitCode {
|
|||
ExitCode::SUCCESS
|
||||
}
|
||||
other => {
|
||||
eprintln!("bread-theme: unknown command '{other}' (try generate|path|print)");
|
||||
eprintln!("bread-theme: unknown command '{other}' (try generate|reload|path|print)");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue