Commit 5893ffda authored by Robert Labudda's avatar Robert Labudda
Browse files

dpass: OTP option

parent a005eea4
......@@ -26,6 +26,10 @@ Use it with `sxhkd` like this:
super + p; u
$HOME/bin/dpass -u
# type a (T)OTP code and hit enter
super + p; o
$HOME/bin/dpass -o
Requirements: gopass, dmenu, xdotool
......
......@@ -19,6 +19,9 @@ parser.add_argument('-u', '--url',
action="store_true",
default=False,
help="Open the URL of a password entry in the system's browser.")
parser.add_argument('-o', '--otp',
action='store_true',
help="Type the OTP value")
args = parser.parse_args(sys.argv[1:])
......@@ -98,6 +101,20 @@ elif args.login:
with subprocess.Popen(["xdotool", "key", "Return"]) as dotool:
pass
elif args.otp:
with subprocess.Popen(["gopass", "otp", selection], stdout=subprocess.PIPE) as gopass:
blob = str(gopass.stdout.read(), 'utf-8')
if blob is None:
sys.exit(-1)
otp, _ = blob.split(' ', 1)
with subprocess.Popen(["xdotool", "type", "--delay", "60", otp]) as dotool:
pass
with subprocess.Popen(["xdotool", "key", "Return"]) as dotool:
pass
else:
with subprocess.Popen(["gopass", "--clip", selection], stdout=subprocess.PIPE) as gopass:
pass
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment