26 lines
624 B
Text
26 lines
624 B
Text
|
#!/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.
|
||
|
' > /dev/stderr
|
||
|
[ "$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
|
||
|
echo 'dotoold: another instance is already connected' > /dev/stderr
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
rm -rf "$p" || exit 1
|
||
|
trap 'rm -rf "$p"' EXIT INT TERM HUP
|
||
|
mkfifo -m 660 "$p" || exit 1
|
||
|
|
||
|
dotool <> "$p"
|