diff --git a/compositor/emoji/font.mbt b/compositor/emoji/font.mbt index 9d5662c..4169c7f 100644 --- a/compositor/emoji/font.mbt +++ b/compositor/emoji/font.mbt @@ -24,7 +24,7 @@ pub fn missing_font_message(env_path : String) -> String { "CHANDRA_EMOJI_FONT=" + env_path + " can't be read as a bitmap (CBDT) colour emoji font. " + "Unset it to use Chandra's own Noto Color Emoji." } else { - "Chandra's emoji font is missing: " + font_path + " (Noto Color Emoji, bitmap edition). " + + "Chandra's emoji font is missing or unreadable: " + font_path + " (Noto Color Emoji, bitmap edition). " + "Run `just install` (or `just emoji-font` in a checkout), then press Super+. again." } } @@ -439,12 +439,13 @@ pub fn EmojiSource::new() -> EmojiSource { { state: None, images: {} } } -///| Open the font: CHANDRA_EMOJI_FONT when set, else the first of `font_paths` that parses. -/// The path, or what to tell the user. Logged once. +///| Open the font: CHANDRA_EMOJI_FONT when set, else `font_path`. The path, or what to tell the +/// user. A failure is tried again on the next call (so fixing the file needs no new session) and +/// logged only when it changes. pub fn EmojiSource::font(self : EmojiSource) -> Result[String, String] { let st = match self.state { - Some(s) => s - None => { + Some(Ok(s)) => Ok(s) + previous => { let env = @sys.getenv("CHANDRA_EMOJI_FONT") let p = if env.length() > 0 { env } else { font_path } let data = @sys.read_file_bytes(p) @@ -458,7 +459,11 @@ pub fn EmojiSource::font(self : EmojiSource) -> Result[String, String] { } match found { Ok((p, f)) => @sys.log("emoji: " + p + " (" + f.ppem.to_string() + " px pictures)") - Err(m) => @sys.log("emoji: " + m) + Err(m) => + match previous { + Some(Err(old)) if old == m => () + _ => @sys.log("emoji: " + m) + } } self.state = Some(found) found diff --git a/scripts/fetch-emoji-font.sh b/scripts/fetch-emoji-font.sh index 35bb341..0d7b59a 100755 --- a/scripts/fetch-emoji-font.sh +++ b/scripts/fetch-emoji-font.sh @@ -12,6 +12,7 @@ sha=72a635cb3d2f3524c51620cdde406b217204e8a6a06c6a096ff8ed4b5fd6e27b url=https://raw.githubusercontent.com/googlefonts/noto-emoji/$version/fonts/NotoColorEmoji.ttf dst=assets/fonts/NotoColorEmoji.ttf if [ -f "$dst" ] && echo "$sha $dst" | sha256sum --check --status; then + chmod 644 "$dst" exit 0 fi echo "fetching Noto Color Emoji $version (10 MB) from $url" >&2 @@ -25,6 +26,7 @@ if ! echo "$sha $tmp" | sha256sum --check --status; then echo "error: $url is not the expected Noto Color Emoji $version (sha256 differs: $(sha256sum "$tmp" | cut -d' ' -f1))" >&2 exit 1 fi +chmod 644 "$tmp" # mktemp made it 0600; the installed copy must be readable by the session's user mv "$tmp" "$dst" trap - EXIT echo "installed $dst" >&2 diff --git a/session/install.py b/session/install.py index fa3f26f..0e27ed8 100755 --- a/session/install.py +++ b/session/install.py @@ -196,6 +196,13 @@ for d in ("config", "wit", "assets"): if os.path.lexists(dst): shutil.rmtree(dst) if os.path.isdir(dst) and not os.path.islink(dst) else os.remove(dst) shutil.copytree(os.path.join(root, d), dst) + # copytree keeps the sources' modes; root installs these and every user's session reads them. + for top, _, files in os.walk(dst): + os.chmod(top, 0o755) + for f in files: + path = os.path.join(top, f) + if not os.path.islink(path): + os.chmod(path, 0o644) print("installed", dst) mods = os.path.join(root, "build/components") dst = os.path.join(share, "modules")