From ac5ae2739245e81f7afa68b67ab2675fcc548f50 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Fri, 2 Dec 2022 06:08:12 +0000 Subject: [PATCH] Update .local/share/chezmoi/home/Library/Fonts/run_onchange_after_add-fonts.tmpl --- .../Fonts/run_onchange_after_add-fonts.tmpl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .local/share/chezmoi/home/Library/Fonts/run_onchange_after_add-fonts.tmpl diff --git a/.local/share/chezmoi/home/Library/Fonts/run_onchange_after_add-fonts.tmpl b/.local/share/chezmoi/home/Library/Fonts/run_onchange_after_add-fonts.tmpl new file mode 100644 index 00000000..3976ecf6 --- /dev/null +++ b/.local/share/chezmoi/home/Library/Fonts/run_onchange_after_add-fonts.tmpl @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +{{- includeTemplate "universal/logg" }} + +{{ $fontFiles := (output "find" (joinPath .chezmoi.homeDir ".local" "share" "fonts") "-type" "f") -}} +{{- range $fontFile := splitList "\n" $fontFiles -}} +{{- if ne $fontFile "" -}} +# {{ $fontFile }} hash: {{ $fontFile | sha256sum }} +{{ end -}} +{{- end }} + +### Ensure all fonts are added to ~/Library/Fonts on macOS +find "$HOME/.local/share/fonts" -type f | while read FONT_FILE; do + BASENAME="$(basename "$FONT_FILE")" + if [ ! -f "$HOME/Library/Fonts/$BASENAME" ] || [ "$(openssl sha256 "$HOME/Library/Fonts/$BASENAME" | sed 's/.*= //')" != "$(openssl sha256 "$FONT_FILE" | sed 's/.*= //')" ]; then + logg info 'Adding `'"$BASENAME"'` to ~/Library/Fonts' + cp "$FONT_FILE" "$HOME/Library/Fonts/$BASENAME" + fi +done