Browse Source

Custom erase timeout when using copy

oz123 10 years ago
parent
commit
ec2b57edcc
4 changed files with 15 additions and 9 deletions
  1. 4 2
      pwman/ui/baseui.py
  2. 6 4
      pwman/ui/mac.py
  3. 4 2
      pwman/ui/win.py
  4. 1 1
      pwman/util/config.py

+ 4 - 2
pwman/ui/baseui.py

@@ -227,8 +227,10 @@ class BaseCommands(HelpUIMixin, AliasesMixin):
         for node in nodes:
             password = ce.decrypt(node[2])
             tools.text_to_clipboards(password)
-            print("erasing in 10 sec...")
-            time.sleep(10)  # TODO: this should be configurable!
+            flushtimeout = self.config.get_value('Global', 'cp_timeout')
+            flushtimeout = flushtimeout or 10
+            print("erasing in {} sec...".format(flushtimeout))
+            time.sleep(int(flushtimeout))
             tools.text_to_clipboards("")
 
     def do_open(self, args):  # pragma: no cover

+ 6 - 4
pwman/ui/mac.py

@@ -45,10 +45,12 @@ class PwmanCliMac(PwmanCli):
 
         for node in nodes:
             password = ce.decrypt(node[2])
-            tools.text_to_clipboards(password)
-            print("erasing in 10 sec...")
-            time.sleep(10)  # TODO: this should be configurable!
-            tools.text_to_clipboards("")
+            tools.text_to_mcclipboard(password)
+            flushtimeout = self.config.get_value('Global', 'cp_timeout')
+            flushtimeout = flushtimeout or 10
+            print("erasing in {} sec...".format(flushtimeout))
+            time.sleep(int(flushtimeout))
+            tools.text_to_mcclipboard("")
 
     def do_cp(self, args):
         self.do_copy(args)

+ 4 - 2
pwman/ui/win.py

@@ -177,8 +177,10 @@ class PwmanCliWin(PwmanCli):
         for node in nodes:
             password = ce.decrypt(node[2])
             winSetClipboard(password)
-            print("erasing in 10 sec...")
-            time.sleep(10)
+            flushtimeout = self.config.get_value('Global', 'cp_timeout')
+            flushtimeout = flushtimeout or 10
+            print("erasing in {} sec...".format(flushtimeout))
+            time.sleep(int(flushtimeout))
             winSetClipboard("")
 
     def do_open(self, args):

+ 1 - 1
pwman/util/config.py

@@ -31,7 +31,7 @@ else:                           # pragma: no cover
 config_dir = os.path.expanduser("~/.pwman")
 
 default_config = {'Global': {'umask': '0100', 'colors': 'yes',
-                             'cls_timeout': '5',
+                             'cls_timeout': '5', 'cp_timeout': '5',
                              'save': 'True'
                              },
                   'Database': {'type': 'SQLite',