From dca08ca52c9000e5ef739cc3afcfbaf7f2f36a49 Mon Sep 17 00:00:00 2001 From: Abel Jimenez Date: Fri, 10 Nov 2023 20:38:57 -0800 Subject: [PATCH 1/2] updated linux install script to fix readme and folder not existing --- util/install_linux.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/install_linux.sh b/util/install_linux.sh index be4569d1..4ec0162e 100755 --- a/util/install_linux.sh +++ b/util/install_linux.sh @@ -3,11 +3,14 @@ # remove all fonts from ~/.local/share/fonts that start with "Monaspace" rm -rf ~/.local/share/fonts/Monaspace* +# make the folder if it does not exist +mkdir -p ~/.local/share/fonts + # copy all fonts from ./otf to ~/.local/share/fonts -cp ./fonts/otf/* ~/.local/share/fonts +cp ../fonts/otf/* ~/.local/share/fonts # copy variable fonts from ./variable to ~/.local/share/fonts -cp ./fonts/variable/* ~/.local/share/fonts +cp ../fonts/variable/* ~/.local/share/fonts # Build font information caches fc-cache -f From dc715805049ae0ccfd8362c9e2e5b345e7272626 Mon Sep 17 00:00:00 2001 From: Abel Jimenez Date: Sat, 11 Nov 2023 10:30:53 -0800 Subject: [PATCH 2/2] merged install into a single script and added messges --- README.md | 4 +-- util/install.sh | 66 +++++++++++++++++++++++++++++++++++++++++++ util/install_linux.sh | 16 ----------- util/install_macos.sh | 10 ------- 4 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 util/install.sh delete mode 100755 util/install_linux.sh delete mode 100644 util/install_macos.sh diff --git a/README.md b/README.md index c5dbf112..57786387 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ There is also a script that automates the deletion of all Monaspace fonts from ` ```bash $ cd util -$ bash ./install_macos.sh +$ bash ./install.sh ``` You can also use [homebrew](https://brew.sh/) as an alternative: @@ -68,7 +68,7 @@ There is also a script which automates the deletion of all Monaspace fonts from ```bash $ cd util -$ bash ./install_linux.sh +$ bash ./install.sh ``` ### Webfonts diff --git a/util/install.sh b/util/install.sh new file mode 100644 index 00000000..7f446357 --- /dev/null +++ b/util/install.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +echo "Starting font installation process..." + +# Get target root directory +if [[ $(uname) == 'Darwin' ]]; then + # MacOS + sys_share_dir="/Library" + usr_share_dir="$HOME/Library" + font_subdir="Fonts" + echo "Detected MacOS. Setting directories accordingly." +else + # Linux + sys_share_dir="/usr/local/share" + usr_share_dir="$HOME/.local/share" + font_subdir="fonts" + echo "Detected Linux. Setting directories accordingly." +fi +if [ -n "${XDG_DATA_HOME}" ]; then + usr_share_dir="${XDG_DATA_HOME}" + echo "Using XDG_DATA_HOME as the user share directory." +fi + +# Function to delete and copy fonts for macOS +install_fonts_mac() { + echo "Removing existing Monaspace fonts from ${usr_share_dir}/${font_subdir}..." + rm -rf ${usr_share_dir}/${font_subdir}/Monaspace* + + echo "Copying new fonts to ${usr_share_dir}/${font_subdir}..." + cp ../fonts/otf/* ${usr_share_dir}/${font_subdir} + cp ../fonts/variable/* ${usr_share_dir}/${font_subdir} + + echo "Fonts successfully installed for MacOS." +} + +# Function to delete and copy fonts for Linux +install_fonts_linux() { + echo "Ensuring font directory exists at ${usr_share_dir}/${font_subdir}..." + mkdir -p ${usr_share_dir}/${font_subdir} + + echo "Removing existing Monaspace fonts from ${usr_share_dir}/${font_subdir}..." + rm -rf ${usr_share_dir}/${font_subdir}/Monaspace* + + echo "Copying new fonts..." + SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + cp $SCRIPT_DIR/../fonts/otf/* ${usr_share_dir}/${font_subdir} + cp $SCRIPT_DIR/../fonts/variable/* ${usr_share_dir}/${font_subdir} + + echo "Rebuilding font information caches..." + fc-cache -f + + echo "Fonts successfully installed for Linux." +} + +# Detect the operating system and install fonts +OS="$(uname)" +if [ "$OS" == "Darwin" ]; then + install_fonts_mac +elif [ "$OS" == "Linux" ]; then + install_fonts_linux +else + echo "Unsupported operating system: $OS" + exit 1 +fi + +echo "Font installation process completed." diff --git a/util/install_linux.sh b/util/install_linux.sh deleted file mode 100755 index 4ec0162e..00000000 --- a/util/install_linux.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# remove all fonts from ~/.local/share/fonts that start with "Monaspace" -rm -rf ~/.local/share/fonts/Monaspace* - -# make the folder if it does not exist -mkdir -p ~/.local/share/fonts - -# copy all fonts from ./otf to ~/.local/share/fonts -cp ../fonts/otf/* ~/.local/share/fonts - -# copy variable fonts from ./variable to ~/.local/share/fonts -cp ../fonts/variable/* ~/.local/share/fonts - -# Build font information caches -fc-cache -f diff --git a/util/install_macos.sh b/util/install_macos.sh deleted file mode 100644 index 5ccc20ba..00000000 --- a/util/install_macos.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# remove all fonts from ~/Library/Fonts that start with "Monaspace" -rm -rf ~/Library/Fonts/Monaspace* - -# copy all fonts from ./otf to ~/Library/Fonts -cp ../fonts/otf/* ~/Library/Fonts - -# copy variable fonts from ./variable to ~/Library/Fonts -cp ../fonts/variable/* ~/Library/Fonts \ No newline at end of file