Add support for not automatically entering insert mode

This commit is contained in:
cryzed 2017-11-01 19:08:49 +01:00
parent 09d55cb271
commit 6d37e4671a

View File

@ -41,6 +41,8 @@ argument_parser.add_argument('--password-pattern', '-P', default=r'(.*)',
help='Regular expression that matches the password')
argument_parser.add_argument('--dmenu-invocation', '-d', default='rofi -dmenu',
help='Invocation used to execute a dmenu-provider')
argument_parser.add_argument('--no-insert-mode', '-n', dest='insert_mode', action='store_false',
help="Don't automatically enter insert mode")
group = argument_parser.add_mutually_exclusive_group()
group.add_argument('--username-only', '-uo', action='store_true', help='Only insert username')
group.add_argument('--password-only', '-po', action='store_true', help='Only insert password')
@ -122,14 +124,15 @@ def main(arguments):
return ExitCodes.COULD_NOT_MATCH_PASSWORD
password = match.group(1)
insert_mode = ';; enter-mode insert' if arguments.insert_mode else ''
if arguments.username_only:
qute_command('fake-key {} ;; enter-mode insert'.format(username))
qute_command('fake-key {}{}'.format(username, insert_mode))
elif arguments.password_only:
qute_command('fake-key {} ;; enter-mode insert'.format(password))
qute_command('fake-key {}{}'.format(password, insert_mode))
else:
# Enter username and password using fake-key and <Tab> (which seems to work almost universally) and switch back
# into insert-mode, so the form can be directly submitted by hitting enter afterwards
qute_command('fake-key {} ;; fake-key <Tab> ;; fake-key {} ;; enter-mode insert'.format(username, password))
qute_command('fake-key {} ;; fake-key <Tab> ;; fake-key {}{}'.format(username, password, insert_mode))
return ExitCodes.SUCCESS