[sxhkd] Fix pipe enabled sxhkd start

This commit is contained in:
Marty Oehme 2020-05-29 14:01:47 +02:00
parent 75a8978a0a
commit 4d96b19163
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
2 changed files with 3 additions and 2 deletions

31
sxhkd/.local/bin/sxhkd-piped Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env sh
# Starting sxhkd without arguments automatically creates
# a fifo pipe in XDG_RUNTIME_DIR, to enable IPC for sxhkd.
# Mostly used for sxhkd-chain-labels script.
type sxhkd >/dev/null 2>&1 || {
return 1
}
# get the complete path to sxhkd to avoid
# recursion later on
PROG="$(type sxhkd)"
PROG="${PROG##* }"
FIFO="$XDG_RUNTIME_DIR"/sxhkd_fifo
# create a fifo and start sxhkd with it
sxhkd() {
exist "$PROG" critical
if [ -n "$1" ]; then
"$PROG" "$@"
else
[ -e "$FIFO" ] && rm "$FIFO"
mkfifo "$FIFO"
"$PROG" -s "$FIFO"
fi
}
sxhkd "$@"