feat: configfile
This commit is contained in:
@@ -5,6 +5,9 @@ set -eu
|
|||||||
# Application info
|
# Application info
|
||||||
. "sh/info.sh"
|
. "sh/info.sh"
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
. "sh/config.sh"
|
||||||
|
|
||||||
# Theme
|
# Theme
|
||||||
. "sh/theme.sh"
|
. "sh/theme.sh"
|
||||||
|
|
||||||
|
|||||||
11
src/sh/config.sh
Normal file
11
src/sh/config.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Main application configuration. This application does not require a
|
||||||
|
# configuration file. However, a configuration file may be stored as
|
||||||
|
# `CONFIGFILE_DEFAULT`. If that file exists, it will be sourced. The path to
|
||||||
|
# the file may be overwritten by specifying the environment variable
|
||||||
|
# `CONFIGFILE`. If a configuration file is specified, then it must also exist.
|
||||||
|
# A configuration file comprises the specification of environment variables
|
||||||
|
# that are allowed to be set.
|
||||||
|
CONFIGFILE_DEFAULT="${XDG_CONFIG_HOME:-"$HOME/.config"}/$APP_NAME/config"
|
||||||
|
CONFIGFILE="${CONFIGFILE:-"$CONFIGFILE_DEFAULT"}"
|
||||||
|
[ "$CONFIGFILE" != "$CONFIGFILE_DEFAULT" ] && [ ! -f "$CONFIGFILE" ] && err "The configuration file manually specified with the environment variable CONFIGFILE=($CONFIGFILE) does not exist." && exit 1
|
||||||
|
[ -f "$CONFIGFILE" ] && . "$CONFIGFILE"
|
||||||
Reference in New Issue
Block a user