initial clipboard support

This commit is contained in:
2021-09-10 14:54:33 -04:00
parent 5c457e4ec0
commit 72f36c5046
2 changed files with 32 additions and 2 deletions
+31 -2
View File
@@ -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':
+1
View File
@@ -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