From 72f36c50466de61c7247cb3697474f541a7b1a35 Mon Sep 17 00:00:00 2001 From: Cuan Date: Fri, 10 Sep 2021 14:54:33 -0400 Subject: [PATCH] initial clipboard support --- usr/bin/{rpass.py => rpass} | 33 +++++++++++++++++++++++++++++++-- usr/share/doc/rpass/changelog | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) rename usr/bin/{rpass.py => rpass} (96%) diff --git a/usr/bin/rpass.py b/usr/bin/rpass similarity index 96% rename from usr/bin/rpass.py rename to usr/bin/rpass index 662ebfd..06d4c17 100755 --- a/usr/bin/rpass.py +++ b/usr/bin/rpass @@ -1,4 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/python3 + +# internal modules from os import system from os import remove @@ -9,6 +11,13 @@ from sys import argv import random import string +# external modules + +import pyperclip + + +# custom modules + def clear(): print("\n" * 100) @@ -49,7 +58,7 @@ def rsyncdown(): # argument - filter the argument to usable text - some replacements are only done once to prevent interference argument = str(argv).replace('[', '', 1).replace(']', '', 1).replace(',', '').replace("'", '') \ - .replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1).replace('./', '', 1).replace('.py', '', 1) + .replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1) # startup help @@ -82,6 +91,7 @@ if argument == 'help' or argument == '--help' or argument == '-h': print('add add an entry') print('gen generate a new password') print('edit edit an existing entry') + print('copy copy the password of an entry to your clipboard') print('remove/-rm delete an existing entry') print('sync/-s manually sync the entry directory via rsync') print() @@ -503,6 +513,25 @@ if argument == 'edit note' or argument == 'edit -n': encrypt() term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'") +# copy + +if argument == 'copy': + print() + term('cd ~/.rpass-store; ls -1 *') + print() + readentry = str(input('Entry to copy: ')) + # generate random strings for /dev/shm + shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) + for _ in range(random.randint(10, 30))) + shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) + for _ in range(random.randint(10, 30))) + term('mkdir -p /dev/shm/' + shmfolder) + # end string and folder generation + term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg') + copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines() + pyperclip.copy(copyline[1].replace('\n', '')) + print() + # gen if argument == 'gen': diff --git a/usr/share/doc/rpass/changelog b/usr/share/doc/rpass/changelog index 7edd652..2af420c 100755 --- a/usr/share/doc/rpass/changelog +++ b/usr/share/doc/rpass/changelog @@ -9,6 +9,7 @@ making any major changes in the future. New features: +- added initial clipboard (password copy) support **overhaul error messages using exceptions **add exceptions for unknown arguments **make clean, colorful file list by exporting to document and removing extensions