Skip to content

Commit

Permalink
Use XDG_DATA_HOME and extract to function
Browse files Browse the repository at this point in the history
  • Loading branch information
erikw committed Dec 7, 2022
1 parent fd5e30f commit 9db9d43
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scripts/variables.sh
Expand Up @@ -23,13 +23,17 @@ TREE_WIDTH_OPTION="@sidebar-tree-width"

SUPPORTED_TMUX_VERSION="1.9"

SIDEBAR_DIR_XDG="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/sidebar"
SIDEBAR_DIR_OLD="$HOME/.tmux/sidebar"
if [ -d "$SIDEBAR_DIR_XDG" ]; then
SIDEBAR_DIR="$SIDEBAR_DIR_XDG"
elif [ -d "$SIDEBAR_DIR_OLD" ]; then
SIDEBAR_DIR="$SIDEBAR_DIR_OLD"
else
SIDEBAR_DIR="$SIDEBAR_DIR_XDG"
fi
unset SIDEBAR_DIR_XDG SIDEBAR_DIR_DEFAULT
sidebar_dir() {
local DIR_XDG="${XDG_DATA_HOME:-$HOME/.local/share}/tmux/sidebar"
local DIR_OLD="$HOME/.tmux/sidebar"

if [ -d "$DIR_XDG" ]; then
echo "$DIR_XDG"
elif [ -d "$DIR_OLD" ]; then
echo "$DIR_OLD"
else
echo "$DIR_XDG"
fi
}

SIDEBAR_DIR="$(sidebar_dir)"

0 comments on commit 9db9d43

Please sign in to comment.