More minor work

This commit is contained in:
Salt 2019-09-26 14:58:36 -05:00
parent 3883f54cdb
commit 2c8c67d307

17
ptgdp
View File

@ -7,8 +7,14 @@
# #
set -e set -e
# Import user-dirs.dirs
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
[ -z "$XDG_MUSIC_DIR" ] && [ -r "$_xdguserdirs" ] && source "$_xdguserdirs"
unset _xdguserdirs
# Read-only set-once variables # Read-only set-once variables
declare -r _name="$(basename -- "$0")" declare -r _name="$(basename -- "$0")"
declare -r _musicdir="${XDG_MUSIC_DIR:-$HOME/Music}"
declare -r _ptgdpmusicdir="$_musicdir/PTGDP Songs"
declare -ra _supportedbackends=("mpd") declare -ra _supportedbackends=("mpd")
# Options # Options
declare -A _config=( declare -A _config=(
@ -18,9 +24,10 @@ declare _optconfigfile="${XDG_CONFIG_HOME:-$HOME/.config}/${_name}.conf"
declare -i _opthelp declare -i _opthelp
declare -i _optverbose=0 declare -i _optverbose=0
# Working variables # Working variables
declare -a _args
declare _return declare _return
# Helper Functions # Helper functions
log() { log() {
# Print a line to the terminal if _optverbose is greater than $2 # Print a line to the terminal if _optverbose is greater than $2
# $2 defaults to 0 # $2 defaults to 0
@ -52,6 +59,9 @@ has() {
return 0 return 0
} }
# More complex helper functions
# Core program functions # Core program functions
printhelp() { printhelp() {
cat << EOF cat << EOF
@ -103,6 +113,11 @@ main() {
fi fi
done < "$_optconfigfile" done < "$_optconfigfile"
fi fi
# Store arguments
shift $((OPTIND - 1))
for arg in "$@"; do
_args+=("$arg")
done
# Validate critical options # Validate critical options
( (
for backend in ${_supportedbackends[@]}; do for backend in ${_supportedbackends[@]}; do