5 # This script is a session launcher for bspwm.
6 # It is based on similar scripts included with Openbox.
9 echo "Usage: bspwm-session"
15 state_prefix=${XDG_CACHE_HOME:-"$HOME/.cache"}
16 mkdir -p "${state_prefix}"
18 if [ ! -d "${state_prefix}" ]; then
19 echo "bspwm-session: cache directory ‘${state_prefix}‘ is missing."
22 elif [ ! -w "${state_prefix}" ]; then
23 echo "bspwm-session: cache directory ‘${state_prefix}‘ is not writable."
28 state_path=$(mktemp -d "${state_prefix}/bspwm-session.XXXXXX")
31 echo "bspwm-session: failed to create state directory ‘${state_path}‘."
36 export BSPWM_SOCKET=${state_path}/bspwm-socket
38 # Trap: make sure everything started in ~/.config/bspwm/autostart is
39 # signalled when this script exits or dies. Also clean up $state_path.
41 for child in $(jobs -p); do
42 jobs -p | grep -q $child && kill $child
45 [[ -d "${state_path}" && -w "${state_path}" ]] && rm -rf -- "${state_path}"
48 trap on_exit EXIT SIGHUP SIGINT SIGTERM
50 # Environment and autostart:
54 "${XDG_CONFIG_HOME:-"$HOME/.config"}/bspwm/autostart"
57 for file in "${source_these[@]}"; do
58 [ -r "${file}" ] && . "${file}"