Create our directories at startup

This commit is contained in:
Salt 2020-09-28 14:05:48 -05:00
parent 97c1d61f0f
commit 5484c4fec6
2 changed files with 10 additions and 3 deletions

View File

@ -60,6 +60,7 @@ Firestarter, in addition to spawning the programs in the default configs, also i
| --: | --- | | --: | --- |
| 0 | Success | | 0 | Success |
| 40 | Firestarter is already running | | 40 | Firestarter is already running |
| 41 | Failed to initialize |
| 50 | Unrecognized argument | | 50 | Unrecognized argument |
| 51 | Invalid option for an argument | | 51 | Invalid option for an argument |
| 52 | Failed to create configuration directory | | 52 | Failed to create configuration directory |

View File

@ -13,9 +13,10 @@ declare -r _name="$(basename -- "$0")"
declare -r _sessionid="$(< /proc/self/sessionid)" declare -r _sessionid="$(< /proc/self/sessionid)"
# Options # Options
declare _optconfigdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name" declare _optconfigdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
declare _optdryrun
declare _optdatadir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name" declare _optdatadir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name"
declare _optrundir="${XDG_RUNTIME_DIR:-/run/user/$UID}/$_name"
declare _optlogdir="$_optdatadir/logs" declare _optlogdir="$_optdatadir/logs"
declare _optdryrun
declare -i _opthelp declare -i _opthelp
declare -i _optverbose declare -i _optverbose
# Working variables # Working variables
@ -225,11 +226,16 @@ step_preexecute() {
[ -n "$_optdryrun" ] && return 0 [ -n "$_optdryrun" ] && return 0
# Execute a user rc if it exists # Execute a user rc if it exists
[ -r "$HOME/.firestarterrc" ] && . "$HOME/.firestarterrc" [ -r "$HOME/.firestarterrc" ] && . "$HOME/.firestarterrc"
#[ -r "$HOME/.xsessionrc" ] && . "$HOME/.xsessionrc"
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
[ -n "$FIRESTARTER" ] && [ "$FIRESTARTER_DISPLAY" == "$DISPLAY" ] error "Firestarter is already running on $DISPLAY: $FIRESTARTER" 55 [ -n "$FIRESTARTER" ] && [ "$FIRESTARTER_DISPLAY" == "$DISPLAY" ] error "Firestarter is already running on $DISPLAY: $FIRESTARTER" 55
export FIRESTARTER="$BASHPID" export FIRESTARTER="$BASHPID"
export FIRESTARTER_DISPLAY="$DISPLAY" export FIRESTARTER_DISPLAY="$DISPLAY"
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
# Create required directories
for dir in $_optconfigdir $_optdatadir $_optrundir $_optlogdir; do
if ! mkdir -p "$dir"; then
error "Failed to create critical directory: $dir" 41
fi
done
# dbus # dbus
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
# We already have a bus started; use it # We already have a bus started; use it