Skip to content

Commit 9fd3c0c

Browse files
committed
Added dotoolc support. Closes #179
1 parent 3d2f6b5 commit 9fd3c0c

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For full installation documention see the [installation docs][docs/install.md].
2929
3. Bemenu, Dmenu, Wmenu, Fuzzel, Rofi, Tofi, Wofi, or Yofi
3030
4. xsel or wl-copy
3131
5. (optional) Pinentry
32-
6. (optional) xdotool (for X), [ydotool][10] or [wtype][11](for Wayland), [dotool][12] (X or Wayland).
32+
6. (optional) xdotool (for X), [ydotool][10] or [wtype][11](for Wayland), [dotool][12] or dotoolc (X or Wayland).
3333

3434
## Features
3535

config.ini.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# editor = <path/to/terminal editor> 'vim' by default
3030
# terminal = <xterm, urxvt> <options if necessary>. 'xterm' by default
3131
# gui_editor = <path/to/editor> <options> e.g. gui_editor = gvim -f
32-
# type_library = pynput (default), xdotool (for alternate keyboard layout support), ydotool (for Wayland), or wtype (also for Wayland)
32+
# 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)
3333
# hide_groups = Recycle Bin <Note formatting for adding multiple groups>
3434
# Group 2
3535
# Group 3

docs/configure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Alternatively you can specify the file path to your config.ini using the -c/--co
2828
| | `editor` | `vim` | |
2929
| | `terminal` | `xterm` | |
3030
| | `gui_editor` | None | |
31-
| | `type_library` | `pynput` | xdotool, ydotool, wtype or pynput |
31+
| | `type_library` | `pynput` | xdotool, ydotool, wtype, dotool, dotoolc or pynput |
3232
| | `hide_groups` | None | See below for formatting of multiple groups |
3333
| | `autotype_default` | `{USERNAME}{TAB}{PASSWORD}{ENTER}` | [Keepass autotype sequences][1] |
3434
| | `type_url` | `False` | |

docs/install.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
4. (optional) Pinentry. Make sure to set which flavor of pinentry command to use
1212
in the config file.
1313
5. (optional) xdotool (for X) or ydotool (>=1.0.0, for Wayland), wtype (for
14-
Wayland), dotool (X or Wayland). If you have a lot of Unicode characters or
15-
use a non-U.S. English keyboard layout, you might have to experiment with
16-
these to determine which works properly for your use case.
14+
Wayland), dotool/dotoolc (X or Wayland). If you have a lot of
15+
Unicode characters or use a non-U.S. English keyboard layout, you might have
16+
to experiment with these to determine which works properly for your use case.
1717

1818
#### Archlinux
1919

keepmenu/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import locale
77
import os
88
import shlex
9+
import shutil
910
from subprocess import run, DEVNULL
1011
import sys
1112
from os.path import exists, expanduser
@@ -99,6 +100,11 @@ def reload_config(conf_file = None): # pylint: disable=too-many-statements,too-
99100
dmenu_err(f"{typ} not installed.\n"
100101
"Please install or remove that option from config.ini")
101102
sys.exit()
103+
if CONF.get("database", "type_library") == "dotoolc":
104+
if shutil.which("dotoolc") is None:
105+
dmenu_err("dotoolc not installed.\n"
106+
"Please install or remove that option from config.ini")
107+
sys.exit()
102108
if os.environ.get('WAYLAND_DISPLAY'):
103109
clips = ['wl-copy -o']
104110
else:

keepmenu/type.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ def type_entry(entry, db_autotype=None):
122122
'xdotool': type_entry_xdotool,
123123
'ydotool': type_entry_ydotool,
124124
'wtype': type_entry_wtype,
125-
'dotool': type_entry_dotool}
125+
'dotool': type_entry_dotool,
126+
'dotoolc': type_entry_dotoolc}
126127
library = keepmenu.CONF.get('database', 'type_library', fallback='pynput')
127128
libraries.get(library, type_entry_pynput)(entry, tokens)
128129

@@ -340,6 +341,35 @@ def type_entry_dotool(entry, tokens):
340341
_ = run(['dotool'], check=True, encoding=keepmenu.ENC, input=f"type {token}")
341342

342343

344+
def type_entry_dotoolc(entry, tokens):
345+
"""Auto-type entry entry using dotoolc (client for dotoold daemon)
346+
347+
"""
348+
from .tokens_dotool import AUTOTYPE_TOKENS
349+
for token, special in tokens:
350+
if special:
351+
cmd = token_command(token)
352+
if callable(cmd):
353+
to_type = cmd(entry) # pylint: disable=not-callable
354+
if to_type is not None:
355+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=f"type {to_type}")
356+
elif token in PLACEHOLDER_AUTOTYPE_TOKENS:
357+
to_type = PLACEHOLDER_AUTOTYPE_TOKENS[token](entry)
358+
if to_type:
359+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=f"type {to_type}")
360+
elif token in STRING_AUTOTYPE_TOKENS:
361+
to_type = STRING_AUTOTYPE_TOKENS[token]
362+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=f"type {to_type}")
363+
elif token in AUTOTYPE_TOKENS:
364+
to_type = " ".join(AUTOTYPE_TOKENS[token])
365+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=to_type)
366+
else:
367+
dmenu_err(f"Unsupported auto-type token (dotoolc): \"{token}\"")
368+
return
369+
else:
370+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=f"type {token}")
371+
372+
343373
def type_text(data):
344374
"""Type the given text data
345375
@@ -358,6 +388,8 @@ def type_text(data):
358388
call(['wtype', '--', data])
359389
elif library == 'dotool':
360390
_ = run(['dotool'], check=True, encoding=keepmenu.ENC, input=f"type {data}")
391+
elif library == 'dotoolc':
392+
_ = run(['dotoolc'], check=True, encoding=keepmenu.ENC, input=f"type {data}")
361393
else:
362394
try:
363395
from pynput import keyboard

0 commit comments

Comments
 (0)