An open API service indexing awesome lists of open source software.

https://github.com/massix/gleamfonts

Small CLI tool to download and install nerdfonts on Termux environment
https://github.com/massix/gleamfonts

cli functional-programming gleam gleam-lang nerdfonts termux tool

Last synced: 6 months ago
JSON representation

Small CLI tool to download and install nerdfonts on Termux environment

Awesome Lists containing this project

README

          

#+HTML:


#+HTML: Project Logo

#+HTML:

* Gleamfonts
Simple command line tool to easily fetch and install [[https://www.nerdfonts.com/][Nerdfonts]] in a [[https://termux.dev/en/][Termux]]
environment.

The tool is written using the [[https://gleam.run/][Gleam programming language]] and needs a working
[[https://www.erlang.org/][Erlang]] VM to be used locally.

** Install from source
You can manually install gleamfonts into your system by following the steps
below.

1. Clone the repository locally, somewhere in your home folder in Termux:
#+begin_src bash
mkdir -p ~/dev
cd ~/dev
git clone https://github.com/massix/gleamfonts.git
cd gleamfonts
#+end_src
2. Install Erlang, Gleam and SQLite using the official package manager:
#+begin_src bash
pkg update && pkg install -y erlang gleam libsqlite
#+end_src
3. Compile the project
#+begin_src bash
make clean install
#+end_src
This step will install the binary distribution inside the
~/data/data/com.termux/files/usr/opt/gleamfonts~ folder, along with a
convenient [[./scripts/gleamfonts][script]] to make it easier to launch the application without
knowing all the details of how to launch an Erlang application. The
script will be installed inside ~/data/data/com.termux/files/usr/bin~,
making it available in your PATH.

To verify that the installation is successful, reload your environment (or
restart the Termux application) and launch ~gleamfonts --help~, you should
be greeted with the help page of the application.

** Install from a release
At the [[https://github.com/massix/gleamfonts/releases][releases]] page, choose the most recent one and download the enclosed
tarball, then extract it into ~/data/data/com.termux/files~ using the
following command:
#+begin_src bash
tar -xzf gleamfonts-x.x.x.tgz --strip-components=1 -C /data/data/com.termux/files
#+end_src

You will still need to install the Erlang VM and the SQLite library using
the default package manager:
#+begin_src bash
pkg update && pkg install erlang libsqlite
#+end_src

** How it works
The first time the program is run, it will fetch all the needed information
from the GitHub's releases page of the [[https://github.com/ryanoasis/nerd-fonts][official repository]], presenting the
user with a wide variety of choices regarding which specific release to use
and which asset (font) to download. Once the user has made their choice,
Gleamfonts will download the corresponding ZIP file and ask the user which
specific variant of the font to install (this is due to the fact that Termux
does not support multiple variants, only a single ttf file can be installed).

Gleamfonts will then extract *that* variant of the chosen font into a
temporary folder and ask the user if they trust Gleamfonts enough to replace
the default Termux font with the newly downloaded one. Should the user
refuse, Gleamfonts will exit right after printing the local path where the
file can be found.

** Translations
Gleamfonts is actually translated in three different languages: English,
French and Italian. By default, it will try to detect which language to use
based on the value of the environment variable ~LANG~. If you want to force
a specific language, you can inject the environment variable at launch time:
#+begin_src bash
LANG=it_IT.UTF-8 gleamfonts --help
#+end_src

#+begin_src
istruzioni: gleamfonts [--delete-cache] [--no-cache] [--help] [--version]
--no-cache recupera tutti i dati da GitHub, ignorando la cache
--delete-cache rimuove la cache esistente prima
--help mostra questa pagina di aiuto ed esci
--version mostra la versione del software ed esci
#+end_src

If you want to add a translation for your language, feel free to submit a
pull request, you just need to add your language under the [[./priv/][priv]] folder, in a
file named following the convention of the UNIX locale (for example:
~de_DE.json~ for the German translation)

* Contributions
All contributions are of course welcome, this is a hobby project and I think
it is simple enough to be used a starting point for learning Gleam. There are
quite some unit tests which should cover most of the codebase.