From 5484c4fec64b9577f8b39b6fd6d4738d668a93b1 Mon Sep 17 00:00:00 2001 From: Salt Date: Mon, 28 Sep 2020 14:05:48 -0500 Subject: [PATCH] Create our directories at startup --- README.md | 1 + firestarter | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dac8fa4..0d835bd 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Firestarter, in addition to spawning the programs in the default configs, also i | --: | --- | | 0 | Success | | 40 | Firestarter is already running | +| 41 | Failed to initialize | | 50 | Unrecognized argument | | 51 | Invalid option for an argument | | 52 | Failed to create configuration directory | diff --git a/firestarter b/firestarter index 62118ff..de0fff5 100755 --- a/firestarter +++ b/firestarter @@ -13,9 +13,10 @@ declare -r _name="$(basename -- "$0")" declare -r _sessionid="$(< /proc/self/sessionid)" # Options declare _optconfigdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name" -declare _optdryrun declare _optdatadir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name" +declare _optrundir="${XDG_RUNTIME_DIR:-/run/user/$UID}/$_name" declare _optlogdir="$_optdatadir/logs" +declare _optdryrun declare -i _opthelp declare -i _optverbose # Working variables @@ -225,11 +226,16 @@ step_preexecute() { [ -n "$_optdryrun" ] && return 0 # Execute a user rc if it exists [ -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 export FIRESTARTER="$BASHPID" 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 if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then # We already have a bus started; use it