diff --git a/dotool.go b/dotool.go index aa02747..7aa5f4b 100644 --- a/dotool.go +++ b/dotool.go @@ -244,6 +244,7 @@ func main() { initKeys(keymap) } + keyboardName := []byte("dotool keyboard") { optset := opt.NewOptionSet() @@ -254,6 +255,11 @@ func main() { }) optset.Alias("h", "help") + optset.Func("keyboard-name", func(s string) error { + keyboardName = []byte(s) + return nil + }) + optset.FlagFunc("list-keys", func() error { listKeys(keymap, LinuxKeys) os.Exit(0) @@ -281,7 +287,7 @@ func main() { } } - keyboard, err := uinput.CreateKeyboard("/dev/uinput", []byte("dotool keyboard")) + keyboard, err := uinput.CreateKeyboard("/dev/uinput", keyboardName) if err != nil { fatal(err.Error()) } diff --git a/dotoold b/dotoold index d2d39a3..48a7789 100755 --- a/dotoold +++ b/dotoold @@ -1,10 +1,15 @@ #!/bin/sh -if [ $# != 0 ]; then - echo 'dotoold runs dotool reading from a pipe for dotoolc to write to. dotoold +for a; do + case "$a" in + -h|--help) + 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.' >&2 - [ "$1" = -h ] || [ "$1" = --help ]; exit -fi + exit + ;; + --) break;; + esac +done fifo_being_read(){ [ -p "$1" ] && /bin/echo 1<>"$1" >"$1" @@ -20,5 +25,5 @@ fi rm -f -- "$p" || exit 1 trap 'rm -f -- "$p"; pkill -P $$; trap - EXIT; exit' EXIT INT TERM HUP mkfifo -m 660 "$p" || exit 1 -dotool <> "$p" & -wait +dotool "$@" <> "$p" & +wait $!