-
Notifications
You must be signed in to change notification settings - Fork 0
/
bspwm-session
executable file
·67 lines (55 loc) · 1.51 KB
/
bspwm-session
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash
#
# bspwm-session
#
# This script is a session launcher for bspwm.
# It is based on similar scripts included with Openbox.
if [ -n "$1" ]; then
echo "Usage: bspwm-session"
echo
exit 1
fi
# Multi-user support:
state_prefix=${XDG_CACHE_HOME:-"$HOME/.cache"}
mkdir -p "${state_prefix}"
if [ ! -d "${state_prefix}" ]; then
echo "bspwm-session: cache directory ‘${state_prefix}‘ is missing."
echo
exit 1
elif [ ! -w "${state_prefix}" ]; then
echo "bspwm-session: cache directory ‘${state_prefix}‘ is not writable."
echo
exit 1
fi
state_path=$(mktemp -d "${state_prefix}/bspwm-session.XXXXXX")
if [ $? -ne 0 ]; then
echo "bspwm-session: failed to create state directory ‘${state_path}‘."
echo
exit 1
fi
export BSPWM_SOCKET=${state_path}/bspwm-socket
# Trap: make sure everything started in ~/.config/bspwm/autostart is
# signalled when this script exits or dies. Also clean up $state_path.
function on_exit {
for child in $(jobs -p); do
jobs -p | grep -q "$child" && kill "$child"
done
# Extra paranoia
[[ -d "${state_path}" && -w "${state_path}" ]] && rm -rf -- "${state_path}"
}
trap on_exit EXIT SIGHUP SIGINT SIGTERM
# Environment and autostart:
source_these=(
"/etc/profile"
"${HOME}/.profile"
"${XDG_CONFIG_HOME:-"$HOME/.config"}/bspwm/autostart"
)
for file in "${source_these[@]}"; do
# shellcheck source=/dev/null
[ -r "${file}" ] && . "${file}"
done
# Launch sxhkd:
create_sxhkdrc
sxhkd &
# Launch bspwm:
bspwm