From b5fb7a082ee198d60fb2b8d36fa343ecbff4648a Mon Sep 17 00:00:00 2001 From: Trevor Bekolay Date: Thu, 19 Mar 2026 14:20:22 -0500 Subject: [PATCH] Added ydotool_key_delay config option. --- config.ini.example | 1 + docs/configure.md | 1 + keepmenu/type.py | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/config.ini.example b/config.ini.example index 04d3ed1..d35aab3 100644 --- a/config.ini.example +++ b/config.ini.example @@ -30,6 +30,7 @@ # terminal = . 'xterm' by default # gui_editor = e.g. gui_editor = gvim -f # type_library = pynput (default), xdotool (for alternate keyboard layout support), ydotool (for Wayland), wtype (also for Wayland), dotool, or dotoolc (dotool client for dotoold daemon) +# ydotool_key_delay = delay between keystrokes for ydotool (default: ydotool's built-in default) # hide_groups = Recycle Bin # Group 2 # Group 3 diff --git a/docs/configure.md b/docs/configure.md index 79e054a..74f9038 100644 --- a/docs/configure.md +++ b/docs/configure.md @@ -29,6 +29,7 @@ Alternatively you can specify the file path to your config.ini using the -c/--co | | `terminal` | `xterm` | | | | `gui_editor` | None | | | | `type_library` | `pynput` | xdotool, ydotool, wtype, dotool, dotoolc or pynput | +| | `ydotool_key_delay` | None | Delay between keystrokes in ms (ydotool only) | | | `hide_groups` | None | See below for formatting of multiple groups | | | `autotype_default` | `{USERNAME}{TAB}{PASSWORD}{ENTER}` | [Keepass autotype sequences][1] | | | `type_url` | `False` | | diff --git a/keepmenu/type.py b/keepmenu/type.py index cf97ce6..9f550e4 100644 --- a/keepmenu/type.py +++ b/keepmenu/type.py @@ -254,6 +254,18 @@ def type_entry_xdotool(entry, tokens): call(['xdotool', 'type', '--', token]) +def _ydotool_type(to_type): + """Type a string using ydotool with optional --key-delay + + """ + cmd = ['ydotool', 'type', '-e', '0'] + key_delay = keepmenu.CONF.get('database', 'ydotool_key_delay', fallback=None) + if key_delay is not None: + cmd.extend(['--key-delay', key_delay]) + cmd.extend(['--', to_type]) + call(cmd) + + def type_entry_ydotool(entry, tokens): """Auto-type entry entry using ydotool @@ -265,14 +277,14 @@ def type_entry_ydotool(entry, tokens): if callable(cmd): to_type = cmd(entry) # pylint: disable=not-callable if to_type is not None: - call(['ydotool', 'type', '-e', '0', '--', to_type]) + _ydotool_type(to_type) elif token in PLACEHOLDER_AUTOTYPE_TOKENS: to_type = PLACEHOLDER_AUTOTYPE_TOKENS[token](entry) if to_type: - call(['ydotool', 'type', '-e', '0', '--', to_type]) + _ydotool_type(to_type) elif token in STRING_AUTOTYPE_TOKENS: to_type = STRING_AUTOTYPE_TOKENS[token] - call(['ydotool', 'type', '-e', '0', '--', to_type]) + _ydotool_type(to_type) elif token in AUTOTYPE_TOKENS: cmd = ['ydotool'] + AUTOTYPE_TOKENS[token] call(cmd) @@ -280,7 +292,7 @@ def type_entry_ydotool(entry, tokens): dmenu_err(f"Unsupported auto-type token (ydotool): \"{token}\"") return else: - call(['ydotool', 'type', '-e', '0', '--', token]) + _ydotool_type(token) def type_entry_wtype(entry, tokens): @@ -383,7 +395,7 @@ def type_text(data): if library == 'xdotool': call(['xdotool', 'type', '--', data]) elif library == 'ydotool': - call(['ydotool', 'type', '-e', '0', '--', data]) + _ydotool_type(data) elif library == 'wtype': call(['wtype', '--', data]) elif library == 'dotool':