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