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

Nerd Fonts Installer Feature Request #160 #308

Closed
fam007e opened this issue Sep 8, 2024 · 0 comments
Closed

Nerd Fonts Installer Feature Request #160 #308

fam007e opened this issue Sep 8, 2024 · 0 comments

Comments

@fam007e
Copy link

fam007e commented Sep 8, 2024

I am often frustrated when trying to install Nerd Fonts on multiple Linux distributions because it requires manual downloading, unpacking, and moving fonts to the appropriate directories. This process can vary across systems due to different package managers and configurations. Additionally, users who want to install multiple fonts must repeat these steps manually for each one.

I would like to see a Nerd Fonts installer integrated into linutil that automates the installation of multiple Nerd Fonts on any Linux distribution. The feature should:

  • Automatically detect the user's operating system and use the appropriate package manager to install necessary dependencies like wget and tar.
  • Provide a user-friendly prompt for selecting which Nerd Fonts to install from a comprehensive list.
  • Download the selected fonts, extract them to the user's local fonts directory, and refresh the system font cache.
  • Be compatible with the existing linutil structure, using helper functions from common-script.sh for dependency checking and environmental setup.

Alternatives to this automated approach include:

  • Manually downloading and installing fonts from the official Nerd Fonts GitHub repository, which can be tedious and error-prone.
  • Using external font management tools, but these often do not integrate well with existing systems or are overly complex for users who just want to install a few fonts.

Neither of these alternatives provides the convenience and integration that a dedicated feature within linutil would offer.

The script should work seamlessly with different Linux distributions and package managers, leveraging linutil’s modular design to ensure compatibility across systems. It should also provide feedback to the user at each step, ensuring transparency during the installation process.

Example output for selecting and installing fonts:

Select fonts to install (separate with spaces):
---------------------------------------------
 0  -  0xProto Nerd Font
 1  -  3270 Nerd Font
 2  -  Agave Nerd Font
 3  -  AnonymicePro Nerd Font
 4  -  Arimo Nerd Font
...
---------------------------------------------

Enter the numbers of the fonts to install (e.g., '0 1 2'): 1 3 4

Downloading and installing 3270 Nerd Font...
Downloading and installing AnonymicePro Nerd Font...
Downloading and installing Arimo Nerd Font...

Fonts installed and cache updated.

Script:
```sh
#!/bin/sh -e

# Import common utilities
. ./common-script.sh

# Function to prompt user for font selection
prompt_font_selection() {
    fonts=(
        "0xProto Nerd Font"
        "3270 Nerd Font"
        "Agave Nerd Font"
        "AnonymicePro Nerd Font"
        "Arimo Nerd Font"
        "AurulentSansMono Nerd Font"
        "BigBlueTerminal Nerd Font"
        "BitstromWera 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"
        "DroidSansMono 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"
        "HeavyDataMono 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"
        "M+ Nerd Font"
        "Noto Nerd Font"
        "OpenDyslexic Nerd Font"
        "Overpass Nerd Font"
        "ProFont Nerd Font"
        "ProggyClean Nerd Font"
        "RecMono 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"
        "ZedMono Nerd Font"
    )

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

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

    echo "Fonts selected: $font_selection"
}

# Function to download and install the selected fonts
download_and_install_fonts() {
    for selection in $font_selection; do
        font=${fonts[$selection]}
        font_name=$(echo "$font" | awk '{print $1}')
        echo "Downloading and installing $font..."
        
        # Check if wget and tar are installed, using common-script.sh helper
        checkCommandRequirements "wget"
        checkCommandRequirements "tar"

        # Download the font
        wget -q --show-progress "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.tar.xz" -P "$HOME/tmp"
        
        # Extract and install the font
        mkdir -p ~/.local/share/fonts
        tar -xf "$HOME/tmp/$font_name.tar.xz" -C "$HOME/.local/share/fonts"
        rm "$HOME/tmp/$font_name.tar.xz"
    done

    # Update the font cache
    fc-cache -vf
    echo "Fonts installed and cache updated."
}

# Function to check environment and dependencies
check_environment() {
    echo "Checking environment..."
    checkEnv  # Assuming this is a function from common-script.sh
}

# Main script execution
check_environment
prompt_font_selection
download_and_install_fonts

This feature would greatly simplify font management and installation, providing a more streamlined experience for users of linutil.

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