2021-07-10 15:57:08 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-05-26 09:46:53 +00:00
|
|
|
# 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 || {
|
2021-07-10 15:57:08 +00:00
|
|
|
return 1
|
2020-05-26 09:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# get the complete path to sxhkd to avoid
|
|
|
|
# recursion later on
|
|
|
|
PROG="$(type sxhkd)"
|
|
|
|
PROG="${PROG##* }"
|
|
|
|
|
|
|
|
FIFO="$XDG_RUNTIME_DIR"/sxhkd_fifo
|
|
|
|
|
2021-07-10 15:57:08 +00:00
|
|
|
args="$*"
|
2020-05-26 09:46:53 +00:00
|
|
|
# create a fifo and start sxhkd with it
|
|
|
|
sxhkd() {
|
2021-07-10 15:57:08 +00:00
|
|
|
exist "$PROG" critical
|
2020-05-26 09:46:53 +00:00
|
|
|
|
2021-07-10 15:57:08 +00:00
|
|
|
if [[ "$args" = *"-s"* ]]; then
|
|
|
|
"$PROG" "$@"
|
|
|
|
else
|
|
|
|
[ -e "$FIFO" ] && rm "$FIFO"
|
2020-05-26 09:46:53 +00:00
|
|
|
|
2021-07-10 15:57:08 +00:00
|
|
|
mkfifo "$FIFO"
|
|
|
|
"$PROG" -s "$FIFO" "$@"
|
|
|
|
fi
|
2020-05-26 09:46:53 +00:00
|
|
|
}
|
2020-05-29 12:01:47 +00:00
|
|
|
|
|
|
|
sxhkd "$@"
|