-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXsession
42 lines (33 loc) · 887 Bytes
/
Xsession
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
#!/bin/bash
# Environment and autostart:
sourceprofile=(
"/etc/profile"
"${HOME}/.profile"
)
# Build Environment
for file in "${sourceprofile[@]}"; do
[ -r "${file}" ] && . "${file}"
done
# Xclm! Environment
export XCLMHOME="${XDG_CONFIG_HOME:-"$HOME/.config"}/xclm"
export XCLMTOOLS="/usr/share/xclm"
export COMMANDS="$XCLMTOOLS:$XCLMHOME/commands"
export EVENTS="$XCLMHOME/events"
export PATH="$PATH:$COMMANDS"
# Build default events
if [ ! -d "$EVENTS" ]; then
mkdir -p "$XCLMHOME/commands"
cp -r "$XCLMTOOLS/events" "$XCLMHOME"
fi
# Trap everything started signalled when this script exits or dies.
cleanexit() {
event-trigger session-end
for child in $(jobs -p); do
jobs -p | grep -q $child && kill $child
done
}
trap cleanexit EXIT SIGHUP SIGINT SIGTERM
# Start daemon
mkfifo "$XCLMHOME/fifo"
event-trigger session-start
event-watch "$EVENTS" > "$XCLMHOME/fifo"