News for hackers. Stuff that matters.
Re:Ask HN: What is your password management solution? by dheera on Saturday July 15, 2017 @01:01PM (#14777628)
By the way, for those wondering about convenience, this will wait 3 seconds (during which you switch to your web browser and click the password field) and then it will "type" the password. (You do NOT want to cut-and-paste your password from a terminal as the clipboard can be read by anything.)

    # requires: sudo apt-get install xautomation for 'xte'

    import time
    from subprocess import Popen, PIPE

    macro = ""

    for char in password:
      if char == '$':
        macro += "keydown Shift_L\nkey 4\nkeyup Shift_L\n"
      elif char == '+':
        macro += "keydown Shift_L\nkey equal\nkeyup Shift_L\n"
      elif char == '/':
        macro += "key slash\n"
      elif char.isupper():
        macro += "keydown Shift_L\nkey %s\nkeyup Shift_L\n" % char
      elif char.islower() or char.isdigit():
        macro += "key %s\n" % char

    print("Entering password in 3 seconds ... [^C to abort]")
    time.sleep(3)

    Popen(['xte'], stdin=PIPE).communicate(macro.encode())
Re:Ask HN: What is your password management solution? by shocks on Saturday July 15, 2017 @06:52PM (#14779523)
I cleaned it up a bit and added the missing keys: https://github.com/wridgers/pwtools/blob/master/bin/pwtype