From 5404859248096c92a181f331f54546d3af2cd7ef Mon Sep 17 00:00:00 2001 From: John Gebbie Date: Thu, 26 Oct 2023 13:09:01 +0100 Subject: [PATCH] replace --keyboard-name with $DOTOOL_KEYBOARD_NAME --- doc/dotool.1.scd | 7 ++++--- dotool.go | 17 +++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/dotool.1.scd b/doc/dotool.1.scd index bbca226..5c3d57f 100644 --- a/doc/dotool.1.scd +++ b/doc/dotool.1.scd @@ -39,6 +39,10 @@ and *DOTOOL_XKB_VARIANT*. For example: *echo type azerty | DOTOOL_XKB_LAYOUT=fr dotool* +You can also specify the name to give the virtual keyboard with the environment +variable *DOTOOL_KEYBOARD_NAME*, which can be useful making rules for your +environment. + Currently the *type* action has only heuristic support for dead keys. # OPTIONS @@ -46,9 +50,6 @@ Currently the *type* action has only heuristic support for dead keys. *-h*, *--help* Print help and exit. -*--keyboard-name=*_NAME_ - Specify the name to give the virtual keyboard device. - *--list-keys* Print the possible Linux keys and exit. diff --git a/dotool.go b/dotool.go index c278ebb..dbdc88d 100644 --- a/dotool.go +++ b/dotool.go @@ -37,10 +37,9 @@ The supported actions are: typedelay MILLISECONDS typehold MILLISECONDS ---keyboard-name=NAME Specify the name to give the keyboard device. ---list-keys Print the possible Linux keys and exit. ---list-x-keys Print the possible XKB keys and exit. ---version Print the version and exit. +--list-keys Print the possible Linux keys and exit. +--list-x-keys Print the possible XKB keys and exit. +--version Print the version and exit. See 'man dotool' for the documentation.`) } @@ -230,7 +229,6 @@ func main() { initKeys(keymap) } - keyboardName := []byte("dotool keyboard") { o := opt.NewOptSet() @@ -241,11 +239,6 @@ func main() { }) o.Alias("h", "help") - o.Func("keyboard-name", func(s string) error { - keyboardName = []byte(s) - return nil - }) - o.FlagFunc("list-keys", func() error { listKeys(keymap, LinuxKeys) os.Exit(0) @@ -273,6 +266,10 @@ func main() { } } + keyboardName := []byte(os.Getenv("DOTOOL_KEYBOARD_NAME")) + if len(keyboardName) == 0 { + keyboardName = []byte("dotool keyboard") + } keyboard, err := uinput.CreateKeyboard("/dev/uinput", keyboardName) if err != nil { fatal(err.Error())