Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to install Nerd fonts in Linutil #160

Open
bungadrum opened this issue Aug 13, 2024 · 1 comment
Open

Add option to install Nerd fonts in Linutil #160

bungadrum opened this issue Aug 13, 2024 · 1 comment

Comments

@bungadrum
Copy link

bungadrum commented Aug 13, 2024

Is your feature request related to a problem? Please describe.
Can you add a optional settings to install Nerd fonts in Linutil. When you open it for the first time and if you don't have them preinstalled you get weird symbols and checkboxes instead.

Describe the solution you'd like
When you run Linutil there could be additional button that says "Install Fonts" and it could list all optional fonts you could install either as a batch or induvidual. Maybe they could be linked with the official website and that's where you would download them from.
https://www.nerdfonts.com/font-downloads

Describe alternatives you've considered
There is a new Flatpak app called Embellish that can install Nerd fonts it could be a option as well
https://flathub.org/apps/io.github.getnf.embellish

Additional context
Add any other context or screenshots about the feature request here.
nerdfonts

@adamperkowski
Copy link
Contributor

Some scripts install needed fonts. Examples:

install_nerd_font() {
FONT_DIR="$HOME/.local/share/fonts"
FONT_ZIP="$FONT_DIR/Meslo.zip"
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_INSTALLED=$(fc-list | grep -i "Meslo")
# Check if Meslo Nerd-font is already installed
if [ -n "$FONT_INSTALLED" ]; then
printf "%b\n" "${GREEN}Meslo Nerd-fonts are already installed.${RC}"
return 0
fi
printf "%b\n" "${YELLOW}Installing Meslo Nerd-fonts${RC}"
# Create the fonts directory if it doesn't exist
if [ ! -d "$FONT_DIR" ]; then
mkdir -p "$FONT_DIR" || {
printf "%b\n" "${RED}Failed to create directory: $FONT_DIR${RC}"
return 1
}
else
printf "%b\n" "${GREEN}$FONT_DIR exists, skipping creation.${RC}"
fi
# Check if the font zip file already exists
if [ ! -f "$FONT_ZIP" ]; then
# Download the font zip file
curl -sSLo "$FONT_ZIP" "$FONT_URL" || {
printf "%b\n" "${RED}Failed to download Meslo Nerd-fonts from $FONT_URL${RC}"
return 1
}
else
printf "%b\n" "${GREEN}Meslo.zip already exists in $FONT_DIR, skipping download.${RC}"
fi
# Unzip the font file if it hasn't been unzipped yet
if [ ! -d "$FONT_DIR/Meslo" ]; then
unzip "$FONT_ZIP" -d "$FONT_DIR" || {
printf "%b\n" "${RED}Failed to unzip $FONT_ZIP${RC}"
return 1
}
else
printf "%b\n" "${GREEN}Meslo font files already unzipped in $FONT_DIR, skipping unzip.${RC}"
fi
# Remove the zip file
rm "$FONT_ZIP" || {
printf "%b\n" "${RED}Failed to remove $FONT_ZIP${RC}"
return 1
}
# Rebuild the font cache
fc-cache -fv || {
printf "%b\n" "${RED}Failed to rebuild font cache${RC}"
return 1
}
printf "%b\n" "${GREEN}Meslo Nerd-fonts installed successfully${RC}"
}

installFont() {
# Check to see if the MesloLGS Nerd Font is installed (Change this to whatever font you would like)
FONT_NAME="MesloLGS Nerd Font Mono"
if fc-list :family | grep -iq "$FONT_NAME"; then
printf "%b\n" "${GREEN}Font '$FONT_NAME' is installed.${RC}"
else
printf "%b\n" "${YELLOW}Installing font '$FONT_NAME'${RC}"
# Change this URL to correspond with the correct font
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_DIR="$HOME/.local/share/fonts"
TEMP_DIR=$(mktemp -d)
curl -sSLo "$TEMP_DIR"/"${FONT_NAME}".zip "$FONT_URL"
unzip "$TEMP_DIR"/"${FONT_NAME}".zip -d "$TEMP_DIR"
mkdir -p "$FONT_DIR"/"$FONT_NAME"
mv "${TEMP_DIR}"/*.ttf "$FONT_DIR"/"$FONT_NAME"
fc-cache -fv
rm -rf "${TEMP_DIR}"
printf "%b\n" "${GREEN}'$FONT_NAME' installed successfully.${RC}"
fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants