1
0
mirror of https://github.com/aquatix/dotfiles.git synced 2025-12-06 21:45:10 +01:00
Files
dotfiles/bin/font_update

66 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
function install_font {
if [ -e "$2" ] && [ ! -L "$2" ]; then
echo "Already exists as real file: $2"
elif [ -L "$2" ]; then
echo "Skipped: $2"
else
echo "Linked font: $2"
ln -s "$1" "$2"
fi
}
IFS=$'\n'
FONTS_CODING=$'SourceCodePro/Bold/Sauce Code Pro Bold Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
SourceCodePro/Medium/Sauce Code Pro Medium Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
SourceCodePro/Medium/Sauce Code Pro Medium Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.ttf
Hack/Bold/Knack Bold Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
Hack/Regular/Knack Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
Hack/BoldOblique/Knack BoldOblique Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.ttf
Hack/RegularOblique/Knack RegularOblique Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.ttf'
FONTS_FUTURA=$'Futura-Std-Bold_19042.ttf
Futura-Std-Bold-Oblique_19041.ttf
Futura-Std-Book_19044.ttf
Futura-Std-Book-Oblique_19043.ttf'
if [ -e ~/.dot_is_server ]; then
# Update from the repo
SOURCE_DIR="/stuff/system/fonts/nerd-fonts/patched-fonts"
DEST_DIR="/stuff/system/sync/fonts/active"
if [ -d "$SOURCE_DIR" ] && [ -d "$DEST_DIR" ]; then
cd "$SOURCE_DIR"
git pull --all
while read -r FONT; do
echo "Copied font: $FONT"
cp -a "$SOURCE_DIR/$FONT" "$DEST_DIR"
done <<< "$FONTS_CODING"
else
echo "$SOURCE_DIR or $DEST_DIR not found, aborting"
fi
else
# Create symlinks if needed
SOURCE_DIR="$HOME/Downloads/sync/fonts/active"
DEST_DIR="$HOME/.local/share/fonts"
if [ ! -e "$DEST_DIR" ]; then
mkdir -p "$DEST_DIR"
fi
if [ -d "$SOURCE_DIR" ]; then
cd "$DEST_DIR"
while read -r FONT; do
FONT_FILE=basename "${FONT}"
install_font "$SOURCE_DIR/$FONT_FILE" "$DEST_DIR/$FONT_FILE"
done <<< "$FONTS_CODING"
while read -r FONT; do
install_font "$SOURCE_DIR/$FONT" "$DEST_DIR/$FONT"
done <<< "$FONTS_FUTURA"
else
echo "$SOURCE_DIR not found, aborting"
fi
if [ -d "$HOME/.fonts" ]; then
echo "Mind that you do have a ~/.fonts dir too, which might contain older versions"
fi
fi