2022-10-20 15:21:20 +02:00
|
|
|
#!/bin/sh
|
|
|
|
if [ $# != 0 ]; then
|
|
|
|
echo 'dotoold runs dotool reading from a pipe for dotoolc to write to.
|
|
|
|
dotoold will exit immediately if the pipe is already being read.
|
|
|
|
The path used for the pipe is $DOTOOL_PIPE else /tmp/dotool_pipe.
|
2022-11-01 11:26:02 +01:00
|
|
|
' >&2
|
2022-10-20 15:21:20 +02:00
|
|
|
[ "$1" = -h ] || [ "$1" = --help ]; exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
fifo_being_read(){
|
|
|
|
[ -p "$1" ] && /bin/echo 1<>"$1" >"$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
p="${DOTOOL_PIPE:-/tmp/dotool_pipe}"
|
|
|
|
|
|
|
|
if fifo_being_read "$p" 2> /dev/null; then
|
2022-11-01 11:26:02 +01:00
|
|
|
echo 'dotoold: another instance is already connected' >&2
|
2022-10-20 15:21:20 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf "$p" || exit 1
|
2022-10-26 12:02:33 +02:00
|
|
|
trap 'rm -rf "$p"; pkill -P $$; trap - EXIT; exit' EXIT INT TERM HUP
|
2022-10-20 15:21:20 +02:00
|
|
|
mkfifo -m 660 "$p" || exit 1
|
2022-10-22 19:37:37 +02:00
|
|
|
dotool <> "$p" &
|
|
|
|
wait
|