Marty Oehme
e617d4ae1e
Moved pictures and videos back to home directory since they are, first, not part of a 'media' collection and, second, on a different share to my personal media assortment.
69 lines
2.7 KiB
Bash
69 lines
2.7 KiB
Bash
#!/usr/bin/env sh
|
|
# XDG Base Directory Specification
|
|
#
|
|
# Sets up necessary environment variables for XDG convention,
|
|
# and those that applications obey for their environments.
|
|
#
|
|
# Thank you remeberYou for the idea
|
|
# see: https://github.com/rememberYou/dotfiles/blob/master/sh/.config/sh/xdg
|
|
#
|
|
# Additionally, home directories are set using the XDG specification,
|
|
# if the xdg-user-dirs module is enabled.
|
|
#
|
|
# Shellcheck will complain about setting permissions for the directories
|
|
# unless it is ignored https://github.com/koalaman/shellcheck/wiki/SC2174
|
|
# shellcheck disable=SC2174
|
|
|
|
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
test "$XDG_CACHE_HOME" || export XDG_CACHE_HOME="$HOME/.cache"
|
|
test "$XDG_CONFIG_HOME" || export XDG_CONFIG_HOME="$HOME/.config"
|
|
test "$XDG_DATA_HOME" || export XDG_DATA_HOME="$HOME/.local/share"
|
|
|
|
# Desktop environment XDG variables - mimics `xdg-user-dirs` settings, only lowercased and not localized
|
|
test "$XDG_DESKTOP_DIR" || export XDG_DESKTOP_DIR="$HOME/desktop"
|
|
test "$XDG_DOCUMENTS_DIR" || export XDG_DOCUMENTS_DIR="$HOME/documents"
|
|
test "$XDG_DOWNLOAD_DIR" || export XDG_DOWNLOAD_DIR="$HOME/downloads"
|
|
test "$XDG_PROJECTS_DIR" || export XDG_PROJECTS_DIR="$HOME/projects"
|
|
|
|
export XDG_MUSIC_DIR="$HOME/media/audio/music"
|
|
export XDG_PICTURES_DIR="$HOME/pictures"
|
|
export XDG_VIDEOS_DIR="$HOME/videos"
|
|
|
|
## Non-Standard additions
|
|
# non-standard, is added to path to enable execution of any files herein
|
|
test "$XDG_BIN_HOME" || export XDG_BIN_HOME="$HOME/.local/bin"
|
|
|
|
xdg_isThere() {
|
|
if [ -e "$1" ] || [ -h "$1" ]; then
|
|
true
|
|
else
|
|
false
|
|
fi
|
|
}
|
|
|
|
xdg_makeForUser() {
|
|
mkdir -p "$1"
|
|
chmod 0700 "$1"
|
|
}
|
|
|
|
## ensure directories exist
|
|
xdg_isThere "$XDG_BIN_HOME" || xdg_makeForUser "$XDG_BIN_HOME"
|
|
xdg_isThere "$XDG_CACHE_HOME" || xdg_makeForUser "$XDG_CACHE_HOME"
|
|
xdg_isThere "$XDG_CONFIG_HOME" || xdg_makeForUser "$XDG_CONFIG_HOME"
|
|
xdg_isThere "$XDG_DATA_HOME" || xdg_makeForUser "$XDG_DATA_HOME"
|
|
|
|
# create xdg-user-dirs if necessary
|
|
xdg_isThere "$XDG_DESKTOP_DIR" || xdg_makeForUser "$XDG_DESKTOP_DIR"
|
|
xdg_isThere "$XDG_DOCUMENTS_DIR" || xdg_makeForUser "$XDG_DOCUMENTS_DIR"
|
|
xdg_isThere "$XDG_DOWNLOAD_DIR" || xdg_makeForUser "$XDG_DOWNLOAD_DIR"
|
|
xdg_isThere "$XDG_MUSIC_DIR" || xdg_makeForUser "$XDG_MUSIC_DIR"
|
|
xdg_isThere "$XDG_PICTURES_DIR" || xdg_makeForUser "$XDG_PICTURES_DIR"
|
|
xdg_isThere "$XDG_VIDEOS_DIR" || xdg_makeForUser "$XDG_VIDEOS_DIR"
|
|
xdg_isThere "$XDG_PROJECTS_DIR" || xdg_makeForUser "$XDG_PROJECTS_DIR"
|
|
|
|
unset -f xdg_isThere xdg_makeForUser
|
|
|
|
## Applications that can be set through environment variables
|
|
export NVM_DIR="$XDG_DATA_HOME/nvm"
|
|
export TMUX_PLUGIN_MANAGER_PATH="$XDG_DATA_HOME/tmux"
|
|
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|