Skip to content

Commit

Permalink
install.sh: Honor XDG_DATA_HOME
Browse files Browse the repository at this point in the history
[why]
When a user sets the XDG_DATA_HOME environment variable the default of
$HOME/.local/share should not be used.

https://wiki.archlinux.org/title/XDG_Base_Directory

[how]
Enable XDG_DATA_HOME to override the default user data directory on Unix
and MacOS platforms.

There is some controversy if XDG_DATA_HOME should be honored on MacOS,
see for example platformdirs (link below). But me also working on Linux
and MacOS (and Windows) in parallel, I can not quite follow the
downsides and believe we should allow XDG_DATA_HOME also for MacOS.

Related: tox-dev/platformdirs#4
Fixes: #1324

Suggested-by: Anthony Foglia <@afoglia>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
  • Loading branch information
Finii committed Jul 28, 2023
1 parent ad8ee0c commit 798d85a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Install Nerd Fonts
__ScriptVersion="0.6"
__ScriptVersion="0.7"

# Default values for option variables:
quiet=false
Expand Down Expand Up @@ -197,15 +197,20 @@ done
# Get target root directory
if [[ $(uname) == 'Darwin' ]]; then
# MacOS
sys_font_dir="/Library/Fonts"
usr_font_dir="$HOME/Library/Fonts"
sys_share_dir="/Library"
usr_share_dir="$HOME/Library"
font_subdir="Fonts"
else
# Linux
sys_font_dir="/usr/local/share/fonts"
usr_font_dir="$HOME/.local/share/fonts"
sys_share_dir="/usr/local/share"
usr_share_dir="$HOME/.local/share"
font_subdir="fonts"
fi
sys_font_dir="${sys_font_dir}/NerdFonts"
usr_font_dir="${usr_font_dir}/NerdFonts"
if [ -n "${XDG_DATA_HOME}" ]; then
usr_share_dir="${XDG_DATA_HOME}"
fi
sys_font_dir="${sys_share_dir}/${font_subdir}/NerdFonts"
usr_font_dir="${usr_share_dir}/${font_subdir}/NerdFonts"

if [[ "system" == "$installpath" ]]; then
font_dir="${sys_font_dir}"
Expand Down

0 comments on commit 798d85a

Please sign in to comment.