1
0
Fork 0
dotfiles/.local/libexec/dwm/autorun

31 lines
607 B
Text
Raw Normal View History

2024-02-07 16:20:29 +01:00
#!/bin/sh
2024-02-17 17:55:49 +01:00
# TODO: Replace this script with tini
2024-02-08 17:04:57 +01:00
trap 'kill $pids $(pidof xcape) 1>/dev/null 2>&1' 2 15 EXIT
2024-02-07 16:20:29 +01:00
2024-02-08 17:04:57 +01:00
LOGFILE="${LOGFILE:-${HOME}/.local/log/session-$(date -I).log}"
2024-02-07 16:20:29 +01:00
2024-02-09 16:30:50 +01:00
log() {
2024-02-07 16:20:29 +01:00
while IFS= read -r line; do
2024-02-09 16:30:50 +01:00
printf "%b" "[$(date +%X)][$1]\t$line\n" >>"${LOGFILE}"
2024-02-07 16:20:29 +01:00
done
}
start() {
2024-02-09 16:30:50 +01:00
logp="${XDG_RUNTIME_DIR:-/tmp}/${1}"
[ -p "$logp" ] || mkfifo "$logp"
cat <"$logp" | log "$1" &
pidof -sx "$1" || "./$1" >"$logp" 2>&1 &
# pidof -sx "$1" || "./$1" 2>&1 | log "$1" &
2024-02-07 16:20:29 +01:00
}
cd "$HOME/.local/libexec/dwm/autorun.d" || exit 1
for s in *; do
start "$s"
pids="$! $pids"
done
wait