ChrisTitusTech / linutil

Chris Titus Tech's Linux Toolbox - Linutil is a distro-agnostic toolbox designed to simplify everyday Linux tasks.
https://christitus.com
MIT License
1.75k stars 158 forks source link

Add option to install Nerd fonts in Linutil #160

Open bungadrum opened 1 month ago

bungadrum commented 1 month ago

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

fam007e commented 1 week ago

Maybe u can incorporate this script for installing nerd fonts:

#!/usr/bin/env bash

# Function to detect the OS and set the package manager
detect_os_and_set_package_manager() {
    if [ -f /etc/os-release ]; then
        . /etc/os-release
        case $ID in
            ubuntu|debian)
                PKG_MANAGER="sudo apt-get update && apt-get install -y"
                ;;
            fedora)
                PKG_MANAGER="sudo dnf install -y"
                ;;
            centos|rhel)
                PKG_MANAGER="sudo yum install -y"
                ;;
            arch)
                PKG_MANAGER="sudo pacman -Syu --noconfirm"
                ;;
            *)
                echo "Unsupported OS: $ID"
                exit 1
                ;;
        esac
    else
        echo "OS detection failed. Please install wget and tar manually."
        exit 1
    fi
}

# Function to check and install dependencies
install_dependencies() {
    if ! command -v wget &>/dev/null; then
        echo "wget not found. Installing wget..."
        $PKG_MANAGER wget
    fi

    if ! command -v tar &>/dev/null; then
        echo "tar not found. Installing tar..."
        $PKG_MANAGER tar
    fi
}

# Detect OS and set package manager
detect_os_and_set_package_manager

# Check and install dependencies
install_dependencies

# Create directory for fonts
mkdir -p ~/.local/share/fonts

# Create tmp directory if it doesn't exist
mkdir -p $HOME/tmp

# List of available fonts
fonts=(
    "0xProto Nerd Font"
    "3270 Nerd Font"
    "Agave Nerd Font"
    "AnonymicePro Nerd Font"
    "Arimo Nerd Font"
    "BlexMono Nerd Font"
    "CaskaydiaCove Nerd Font"
    "CaskaydiaMono Nerd Font"
    "CodeNewRoman Nerd Font"
    "ComicShannsMono Nerd Font"
    "CommitMono Nerd Font"
    "Cousine Nerd Font"
    "D2Coding Nerd Font"
    "DaddyTimeMono Nerd Font"
    "DejaVuSansMono Nerd Font"
    "EnvyCodeR Nerd Font"
    "FantasqueSansMono Nerd Font"
    "FiraCode Nerd Font"
    "FiraMono Nerd Font"
    "GeistMono Nerd Font"
    "GoMono Nerd Font"
    "Gohu Nerd Font"
    "Hack Nerd Font"
    "Hasklug Nerd Font"
    "Hurmit Nerd Font"
    "iM-Writing Nerd Font"
    "Inconsolata Nerd Font"
    "InconsolataGo Nerd Font"
    "Inconsolata LGC Nerd Font"
    "IntoneMono Nerd Font"
    "Iosevka Nerd Font"
    "IosevkaTerm Nerd Font"
    "IosevkaTermSlab Nerd Font"
    "JetBrainsMono Nerd Font"
    "Lekton Nerd Font"
    "Literation Nerd Font"
    "Lilex Nerd Font"
    "MartianMono Nerd Font"
    "Meslo Nerd Font"
    "Monaspice Nerd Font"
    "Monofur Nerd Font"
    "Monoid Nerd Font"
    "Mononoki Nerd Font"
    "Noto Nerd Font"
    "OpenDyslexic Nerd Font"
    "Overpass Nerd Font"
    "ProFont Nerd Font"
    "ProggyClean Nerd Font"
    "RobotoMono Nerd Font"
    "SauceCodePro Nerd Font"
    "ShureTechMono Nerd Font"
    "SpaceMono Nerd Font"
    "Terminess Nerd Font"
    "Tinos Nerd Font"
    "Ubuntu Nerd Font"
    "UbuntuMono Nerd Font"
    "VictorMono Nerd Font"
)

# Display menu of available fonts
echo "Select fonts to install (separate with spaces):"
echo "---------------------------------------------"
for i in "${!fonts[@]}"; do
    echo " $i  -  ${fonts[i]}"
done
echo "---------------------------------------------"

# Prompt user to select fonts
read -rp "Enter the numbers of the fonts to install (e.g., '0 1 2'): " font_selection

# Download and install selected fonts
for selection in $font_selection; do
    font=${fonts[$selection]}
    echo "Downloading and installing $font..."
    font_name=$(echo "$font" | awk '{print $1}')
    wget -q --show-progress "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.tar.xz" -P $HOME/tmp
    tar -xf "$HOME/tmp/$font_name.tar.xz" -C "$HOME/.local/share/fonts"
    rm "$HOME/tmp/$font_name.tar.xz"
done

# Update font cache
fc-cache -vf