* usr/lib/byobu/include/dirs.in: #LP:1973362

- improve BYOBU_CONFIG_DIR / XDG handling, simplifying logic and
    not requiring user to both create the dir and set an env var.
    Change logic to: BYOBU_CONFIG_DIR if set, ~/.byobu if exists, else
    XDG_CONFIG_DIR(~/.config)/byobu. Always create the dir if needed.
This commit is contained in:
MestreLion 2022-05-13 13:33:06 -03:00
commit 7184490f54

View file

@ -25,22 +25,19 @@ PKG="byobu"
[ -n "$BYOBU_PREFIX" ] || BYOBU_PREFIX="@prefix@" [ -n "$BYOBU_PREFIX" ] || BYOBU_PREFIX="@prefix@"
# Create and export the user configuration directory # Create and export the user configuration directory
if [ -d "$BYOBU_CONFIG_DIR" ]; then # BYOBU_CONFIG_DIR if set, ~/.byobu if it exists, otherwise XDG_CONFIG_HOME/byobu
export BYOBU_CONFIG_DIR="$BYOBU_CONFIG_DIR" if [ -z "$BYOBU_CONFIG_DIR" ]; then
elif [ -d "$XDG_CONFIG_HOME" ]; then if [ -d "$HOME/.$PKG" ]; then
# Use XDG, as some users insist on such nonsense :-) export BYOBU_CONFIG_DIR="$HOME/.$PKG"
export BYOBU_CONFIG_DIR="$XDG_CONFIG_HOME/$PKG" else
elif [ -d "$HOME/.config/$PKG" ]; then _xdg="${XDG_CONFIG_HOME:-"$HOME"/.config}"
# Use XDG config directory, if it exists # Spec says XDG_CONFIG_HOME must not be world-readable
export BYOBU_CONFIG_DIR="$HOME/.config/$PKG" [ -d "$_xdg" ] || mkdir -p -m 700 "$_xdg"
elif [ -d "$HOME/.local/share/$PKG" ]; then export BYOBU_CONFIG_DIR="$_xdg/$PKG"
# Use XDG local directory, if it exists unset _xdg
export BYOBU_CONFIG_DIR="$HOME/.local/share/$PKG" fi
else
# And to default to good old classic config dir location!
export BYOBU_CONFIG_DIR="$HOME/.$PKG"
fi fi
[ -d "$BYOBU_CONFIG_DIR" ] || mkdir -p "$BYOBU_CONFIG_DIR/bin" [ -d "$BYOBU_CONFIG_DIR/bin" ] || mkdir -p "$BYOBU_CONFIG_DIR/bin"
# Grab the global, then local socket directory # Grab the global, then local socket directory
[ -r "/etc/$PKG/socketdir" ] && . "/etc/$PKG/socketdir" [ -r "/etc/$PKG/socketdir" ] && . "/etc/$PKG/socketdir"