alexmyczko / fnt

apt for fonts, the missing font manager for macOS/linux
Other
489 stars 20 forks source link

$XDG_CACHE_HOME vs. $TMPDIR #6

Closed ramses0 closed 2 months ago

ramses0 commented 3 years ago

https://github.com/alexmyczko/fnt/blob/63a55a8c8dec3b38fe6d0c720f366e43fcda79dd/fnt#L9

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

The simplest "closer" answer would be: TMPDIR="$HOME/.cache/fnt" (note double quotes so that http://shellcheck.net doesn't yell at you for "what if your $USER has spaces in it?"

Likely more correct would be: CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}/fnt"

https://wiki.bash-hackers.org/syntax/pe#use_a_default_value
echo "Your home directory is: ${HOME:-/home/$USER}."

...then either remove the cache dir you control after each execution, or maybe provide some sort of --cache support.

LOVE your code, the $TO_CHECK && $INSTALLER technique is awesome for non-package-manager-based scripts. If you're amenable, I'd probably mess around and submit a patch for some of this or would be happy to discuss, as I love some of the potential that this utility has.

alexmyczko commented 3 years ago

@ramses0 thank you! you might like some more technique for example in these: https://github.com/alexmyczko/uapt-get (i had created this for linux accounts i have without root access) https://github.com/alexmyczko/iBackup (some very old stuff, but hey, still works ;) https://github.com/alexmyczko/ree (shell script version) https://github.com/alexmyczko/sk (i'm aware there's watchdog(d)) https://github.com/alexmyczko/livecd.gnustep.org (vga palette color change ansi codes) https://github.com/alexmyczko/autoexec.bat/blob/master/fsbench (ctrl-c handling) https://github.com/alexmyczko/autoexec.bat/blob/master/led-indicator (for keyboards with 3 leds) https://github.com/alexmyczko/autoexec.bat/blob/master/sw (software packaging diversity overview) if you like the application directories like gobolinux: https://github.com/alexmyczko/autoexec.bat/blob/master/makeappsdirs

sorry for the late answer, i got overwhelmed by the reactions. so the plan is to add somehow more font sources, and support more systems, and add more functionality

ramses0 commented 3 years ago

Contrary, I appreciate the response. See if you can get shellcheck installed to your editor (vim and syntastic I think is my recipe). It will ingrain some good habits to you. I’ll keep an eye on fnt ... it would be especially nice to have tooling/api to enable/disable categories (metadata) of fonts. Serif, Script, Mono, International, large/limited charset. Numerics, upper/lower, etc. 

Sent from Yahoo Mail for iPhone

On Friday, February 12, 2021, 11:45 AM, Alex Myczko notifications@github.com wrote:

@ramses0 thank you! you might like some more technique for example in these: https://github.com/alexmyczko/uapt-get (i had created this for linux accounts i have without root access) https://github.com/alexmyczko/iBackup (some very old stuff, but hey, still works ;) https://github.com/alexmyczko/ree (shell script version) https://github.com/alexmyczko/sk (i'm aware there's watchdog(d)) https://github.com/alexmyczko/livecd.gnustep.org (vga palette color change ansi codes) https://github.com/alexmyczko/autoexec.bat/blob/master/fsbench (ctrl-c handling) https://github.com/alexmyczko/autoexec.bat/blob/master/led-indicator (for keyboards with 3 leds) https://github.com/alexmyczko/autoexec.bat/blob/master/sw (software packaging diversity overview) if you like the application directories like gobolinux: https://github.com/alexmyczko/autoexec.bat/blob/master/makeappsdirs

sorry for the late answer, i got overwhelmed by the reactions. so the plan is to add somehow more font sources, and support more systems, and add more functionality

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

crpb commented 3 months ago

There is no more so called cache in use. Everything in ~/.fnt is needed for searching and indexing the installed fonts. And those few megs should be available on any system.

~/.fnt % du -sch *
5.0K    APACHE.xz
24K     index
93K     OFL.xz
4.6M    Packages.xz
4.7M    total

And the Packages.xz could be slimed down to only what we need (fonts-*)

done

merwok commented 3 months ago

In this case, it would be nice to follow the BaseDir Spec to place the config directory in XDG_BASE_HOME

crpb commented 3 months ago

XDG_BASE_HOME

do you mean ~/.config or ~/.local/share? XDG_BASE_HOME isn't defined

merwok commented 3 months ago

Oops! It’s the Base Dir Spec, but I meant XDG_CONFIG_HOME for the envvar. But it should be XDG_DATA_HOME indeed if these are data files, not user-editable config files.

crpb commented 2 months ago

But it should be XDG_DATA_HOME indeed if these are data files, not user-editable config files.

Yeah, that was also my thought if we change that at all.

So ~/.local/share/fnt/ and maybe we add some functionality in the future to provide some configurable things like "only give me debian fonts but not those from google" we could put it in ~/.config/fnt/.

merwok commented 2 months ago

(To be precise: the dir should be $XDG_DATA_HOME if defined, otherwise fall back to ~/.local/share)

crpb commented 2 months ago

I know, i was gonna edit my message to make it totaly clear but then thought... meh he will know what i mean 🙈

crpb commented 2 months ago

@merwok if you could please try if everything is in order w/o gh you could just clone my fork and run ./fnt from that dir.

crpb commented 2 months ago

oh, i just thought of one thing i maybe should add ... the check if ~/.local/share/ even exists because otherwise i should revert it to the old style i guess.