Commit a005eea4 authored by R's avatar R
Browse files

dpass: open url in browser

parent 81f3692b
Utils
=====
dpass
-----
A convenience wrapper for [`gopass`](https://www.gopass.pw) to be used with [`dmenu`](https://tools.suckless.org/dmenu/). It can copy a password to clipboard or type it using [`xdotool`](https://github.com/jordansissel/xdotool).
Use it with `sxhkd` like this:
# ~/.config/sxhkd/sxhkdrc
# copy password to clipboard
super + p; c
$HOME/bin/dpass
# type password (password, enter)
super + p; t
$HOME/bin/dpass -t
# type in the full login (username, tab, password, enter)
super + p; l
$HOME/bin/dpass -l
# open the url of that password entry in your preferred browser
super + p; u
$HOME/bin/dpass -u
Requirements: gopass, dmenu, xdotool
getpassword.sh
--------------
......
......@@ -3,6 +3,7 @@
import sys
import argparse
import subprocess
import webbrowser
parser = argparse.ArgumentParser()
......@@ -14,6 +15,10 @@ parser.add_argument('-l', '--login',
action="store_true",
default=False,
help="Type a login (username, tab, password, enter)")
parser.add_argument('-u', '--url',
action="store_true",
default=False,
help="Open the URL of a password entry in the system's browser.")
args = parser.parse_args(sys.argv[1:])
......@@ -51,6 +56,22 @@ if args.type:
pass
with subprocess.Popen(["xdotool", "key", "Return"]) as dotool:
pass
elif args.url:
with subprocess.Popen(["gopass", "show", "--force", selection], stdout=subprocess.PIPE) as gopass:
blob = str(gopass.stdout.read(), 'utf-8')
if blob is None:
sys.exit(-1)
url = None
for line in blob.split("\n")[1:]:
if ':' in line and line.split(':', 1)[0].lower() in ['url']:
url = line.split(':', 1)[1].strip()
break
if url is not None:
webbrowser.open(url, new=2)
elif args.login:
with subprocess.Popen(["gopass", "show", "--force", selection], stdout=subprocess.PIPE) as gopass:
blob = str(gopass.stdout.read(), 'utf-8')
......
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