dotfiles/sxhkd/.local/bin/sxhkd-piped

33 lines
638 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# 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
args="$*"
# create a fifo and start sxhkd with it
sxhkd() {
exist "$PROG" critical
if [[ "$args" = *"-s"* ]]; then
"$PROG" "$@"
else
[ -e "$FIFO" ] && rm "$FIFO"
mkfifo "$FIFO"
"$PROG" -s "$FIFO" "$@"
fi
}
2020-05-29 12:01:47 +00:00
sxhkd "$@"