Commit 03bb2e0c authored by Benedikt Vollmerhaus's avatar Benedikt Vollmerhaus

Add install task for downloading fonts, Refactor install tasks

parent 623f530c
#!/usr/bin/env sh
# shellcheck disable=SC2059
# Downloads the latest patched 'M+ 1m' font from the Nerd Fonts repository,
# copies it to the user's local fonts directory and updates the font cache.
#
# Author: Benedikt Vollmerhaus
# License: MIT
set -e
NC='\033[0m'
GREEN='\033[32m'
LOCAL_FONT_DIR="$HOME/.local/share/fonts"
DL_URL='https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/MPlus/%s/complete/%s'
# The font variants to download. These correspond to the directories at:
# https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/MPlus
FONT_STYLES='Bold
Light
Medium
Regular
Thin'
# The file names of the fonts to download. The placeholder is replaced
# with the font style name, or removed if the font style is 'Regular'.
FONT_FILENAMES='M+ 1m %sNerd Font Complete.ttf
M+ 1m %sNerd Font Complete Mono.ttf'
download_font() {
font_style=$1
font_filename=$2
# All font styles except 'Regular' include the style in the file name
if [ "$font_style" != 'Regular' ]; then
font_style_lc=$(printf "$font_style" | tr '[:upper:]' '[:lower:]')
font_filename=$(printf "$font_filename" "$font_style_lc ")
else
font_filename=$(printf "$font_filename" '')
fi
# Replace spaces in the font file name with '%20' for use in the URL
font_url_filename=$(printf "$font_filename" | sed 's/ /%20/g')
url=$(printf "$DL_URL" "$font_style" "$font_url_filename")
printf " [ .. ] %s\\n" "$font_filename"
curl -fLsS "$url" > "$font_filename"
printf "\\b\\r [ ${GREEN}ok${NC} ] %s\\n" "$font_filename"
}
update_font_cache() {
if command -v fc-cache >/dev/null 2>&1; then
printf ":: Updating font cache...\\n"
fc-cache -f "$LOCAL_FONT_DIR"
fi
}
main() {
mkdir -p "$LOCAL_FONT_DIR"
cd "$LOCAL_FONT_DIR" || return
printf ":: Retrieving fonts...\\n"
IFS=$'\n'
for font_style in ${FONT_STYLES}; do
for font_filename in ${FONT_FILENAMES}; do
download_font "$font_style" "$font_filename"
done
done
update_font_cache
}
main
# kak:filetype=sh
#!/usr/bin/env sh
# Optional post-install tasks for my dotfiles, such as installing dependencies.
# Installs Python dependencies for the included desktop scripts using pip.
#
# Author: Benedikt Vollmerhaus
# License: MIT
......@@ -26,10 +26,12 @@ install_pip_packages() {
fi
}
printf "Install Python dependencies for scripts submodule? [Y/n] "
read -r choice
if echo "$choice" | grep -Eq '^[Yy]?$'; then
main() {
if check_pip_available; then
install_pip_packages
fi
fi
}
main
# kak:filetype=sh
......@@ -21,11 +21,11 @@
~/.config/rofi: config/rofi
~/.config/wal/templates: config/wal/templates
~/.vimrc: vimrc
~/.Xresources: Xresources
~/.vimrc: config/vimrc
~/.Xresources: config/Xresources
- shell:
- command: ./install-tasks
- command: ./run-install-tasks
stdin: true
stdout: true
stderr: true
#!/usr/bin/env sh
# Optional post-install tasks for my dotfiles, such as installing dependencies.
#
# Author: Benedikt Vollmerhaus
# License: MIT
printf ":: Install Python dependencies for scripts submodule? [Y/n] "
read -r choice
if echo "$choice" | grep -Eq '^[Yy]?$'; then
./install-tasks/install-pip
fi
printf ":: Download patched M+ font (~25 MB) from Nerd Fonts? [Y/n] "
read -r choice
if echo "$choice" | grep -Eq '^[Yy]?$'; then
./install-tasks/install-fonts
fi
# kak:filetype=sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment