From 09d55cb271f8e7cfeb58f0229006aea4931b71f5 Mon Sep 17 00:00:00 2001 From: cryzed Date: Wed, 1 Nov 2017 19:01:17 +0100 Subject: [PATCH] Add support for only inserting the username or password --- misc/userscripts/qute-passmenu | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/misc/userscripts/qute-passmenu b/misc/userscripts/qute-passmenu index 12d7c5b40..9c77f61a8 100755 --- a/misc/userscripts/qute-passmenu +++ b/misc/userscripts/qute-passmenu @@ -41,6 +41,9 @@ 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') +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') stderr = functools.partial(print, file=sys.stderr) @@ -119,9 +122,15 @@ def main(arguments): return ExitCodes.COULD_NOT_MATCH_PASSWORD password = match.group(1) - # Enter username and password using fake-key and (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 ;; fake-key {} ;; enter-mode insert'.format(username, password)) + if arguments.username_only: + qute_command('fake-key {} ;; enter-mode insert'.format(username)) + elif arguments.password_only: + qute_command('fake-key {} ;; enter-mode insert'.format(password)) + else: + # Enter username and password using fake-key and (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 ;; fake-key {} ;; enter-mode insert'.format(username, password)) + return ExitCodes.SUCCESS