From 6a033f2b20f12cee09db6993584d12551ee83dc7 Mon Sep 17 00:00:00 2001 From: brejela Date: Thu, 23 Dec 2021 11:25:28 -0300 Subject: [PATCH] ADD: Added copy command --- CHANGELOG | 4 +++- README.md | 11 ++++++++++- steelbox.py | 25 ++++++++++++++++++++----- steelbox.sh | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cc02e49..da9058e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,4 +11,6 @@ · Added delete command when on the main window - 0.4: · Minor UI tweaks - · Added 'modify' command \ No newline at end of file + · Added 'modify' command +- 0.5: + · Added "copy password to clipboard" command \ No newline at end of file diff --git a/README.md b/README.md index 22d24e7..44a9957 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,15 @@ Steelbox is a password manager that uses the curses library for interactive term ### Installation (and upgrade): Just run `install.sh` **WITHOUT SUDO** + If you're upgrading Steelbox, don't worry: `install.sh` will do it automatically without messing with your password file #### Dependencies: -The standard ( this program was made with 3.10 ) python installation comes with the `curses` and `csv` modules, just make sure you have [GnuPG](https://gnupg.org/) installed \ No newline at end of file +As of V0.5, you need the [pyperclip](https://pypi.org/project/pyperclip/) module. You can install it with [pip](https://pypi.org/project/pip/): + +`pip3 install pyperclip` + +Also, for clipboard support to work, you need [xclip](https://github.com/astrand/xclip) or [xsel](https://github.com/kfish/xsel) on your machine. + +This program has no support for the wayland clipboard. + +The standard ( this program was made with 3.10 ) python installation comes with the `curses` and `csv` modules, just make sure you have [GnuPG](https://gnupg.org/) installed. \ No newline at end of file diff --git a/steelbox.py b/steelbox.py index d01c042..490f794 100644 --- a/steelbox.py +++ b/steelbox.py @@ -4,6 +4,7 @@ from curses import wrapper from curses.textpad import Textbox import sys import os +import pyperclip as pc version = sys.argv[1] ## Initialization of bottomline dependencies @@ -155,7 +156,7 @@ def main(stdscr): COLUMN+=16 NROWS+=1 mainwin.refresh() - STATUS_MESSAGE = "cmds: PrvPage(F1),NxtPage(F2),(d|el)ete,(e)xamine,(n)ew, (m)odify,(q)uit" + STATUS_MESSAGE = "cmds: PrvPage(F1),NxtPage(F2),(d|el)ete,(e)xamine,(n)ew,(c)opy,(m)odify,(q)uit" statusWin.addstr(0,0, STATUS_MESSAGE) statusWin.refresh() @@ -193,6 +194,14 @@ def main(stdscr): if CURR_PAGE < MAX_PAGES: CURR_PAGE+=1 GLOBAL_CURSOR+=MAX_ITEMS + + elif c == ord('c') or c == curses.KEY_F3: + pc.copy(files[GLOBAL_CURSOR]['pswd']) + statusWin.border() + STATUS_MESSAGE = "Copied password for " + files[GLOBAL_CURSOR]['service'] + statusWin.addstr(0,0, STATUS_MESSAGE) + statusWin.refresh() + mainwin.getch() elif c == ord('d') or c == curses.KEY_DC: dlWin = curses.newwin(3, 22, int(TERM_LINES/2), int(TERM_COLS/2)) @@ -241,7 +250,7 @@ def main(stdscr): fileWin.addstr(2, 1, "NAME: " + passUser) fileWin.addstr(3, 1, "PSWD: " + passPswd) statusWin.border() - STATUS_MESSAGE = "cmds:(d|DEL)ete,(m)odify " + STATUS_MESSAGE = "cmds:(d|DEL)ete,(m)odify, (c)opy " statusWin.addstr(0,0, STATUS_MESSAGE) statusWin.refresh() fileWin.refresh() @@ -291,8 +300,7 @@ def main(stdscr): psWin.addstr(0, 0, modFile['pswd']) psWin.move(0, 0) psBox = Textbox(psWin) - - + # Clears the 'modify password' window modWin.border() modWin.border() @@ -338,7 +346,14 @@ def main(stdscr): csvreader=csv.DictReader(pasfile) for ids in csvreader: files.append(ids) - + + elif c == ord('c') or c == curses.KEY_F3: + pc.copy(files[GLOBAL_CURSOR]['pswd']) + statusWin.border() + STATUS_MESSAGE = "Copied password for " + files[GLOBAL_CURSOR]['service'] + statusWin.addstr(0,0, STATUS_MESSAGE) + statusWin.refresh() + mainwin.getch() elif c == ord('n'): diff --git a/steelbox.sh b/steelbox.sh index edb78d3..607d37b 100755 --- a/steelbox.sh +++ b/steelbox.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version="0.4" +version="0.5" echo Steelbox V$version