mirror of
https://github.com/aquatix/dotfiles.git
synced 2025-12-07 00:05:10 +01:00
93 lines
3.4 KiB
Bash
Executable File
93 lines
3.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=$'Hack/Bold/complete/Knack Bold Nerd Font Complete Mono.ttf
|
|
Hack/Regular/complete/Knack Regular Nerd Font Complete Mono.ttf
|
|
Hack/BoldItalic/complete/Knack Bold Italic Nerd Font Complete Mono.ttf
|
|
Hack/Italic/complete/Knack Italic Nerd Font Complete Mono.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'
|
|
|
|
# https://github.com/eosrei/emojione-color-font/
|
|
FONTS_VARIOUS=$'EmojiOneColor-SVGinOT.ttf'
|
|
|
|
FONTS_DELETE=$'Sauce Code Pro Medium Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Sauce Code Pro Bold Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Sauce Code Pro Medium Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Knack Bold Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Knack Plus Nerd File Types Mono Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Knack BoldOblique Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.ttf
|
|
Knack RegularOblique Plus Nerd File Types Plus Font Awesome Plus Octicons Plus Pomicons.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 "${SOURCE_DIR}/${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"
|
|
while read -r FONT; do
|
|
install_font "$SOURCE_DIR/$FONT" "$DEST_DIR/$FONT"
|
|
done <<< "$FONTS_VARIOUS"
|
|
# Just to be sure, clear your font cache and restart Firefox
|
|
if [ ! -e "${HOME}/.config/fontconfig" ]; then
|
|
mkdir -p "${HOME}/.config/fontconfig"
|
|
fi
|
|
if [ ! -e "${HOME}/.config/fontconfig/fonts.conf" ]; then
|
|
ln -s "${SOURCE_DIR}/fonts.conf" "${HOME}/.config/fontconfig/"
|
|
fi
|
|
fc-cache -f -v
|
|
echo 'You might want to restart your browser'
|
|
# Delete obsolete fonts
|
|
while read -r FONT; do
|
|
if [ -L "$DEST_DIR/$FONT" ]; then
|
|
echo "Deleting symlink $DEST_DIR/$FONT"
|
|
rm "$DEST_DIR/$FONT"
|
|
fi
|
|
done <<< "$FONTS_DELETE"
|
|
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
|