From 6a9d14b51473ed2602ea218695dc84eb38e9f483 Mon Sep 17 00:00:00 2001 From: Daniel STAN <daniel.stan@crans.org> Date: Tue, 12 Jun 2012 10:35:26 +0200 Subject: [PATCH] =?UTF-8?q?[safety]=20Empiler/D=C3=A9piler=20le=20presse-p?= =?UTF-8?q?apier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cranspasswords.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cranspasswords.py b/cranspasswords.py index 2af399b..1ab4526 100755 --- a/cranspasswords.py +++ b/cranspasswords.py @@ -220,7 +220,24 @@ def show_roles(): if role.endswith('-w'): continue print " * " + role +old_clipboard = None +def saveclipboard(restore=False): + global old_clipboard + if restore and old_clipboard == None: + return + act = '-in' if restore else '-out' + proc =subprocess.Popen(['xclip',act,'-selection','clipboard'],\ + stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=sys.stderr) + if not restore: + old_clipboard = proc.stdout.read() + else: + raw_input("Appuyez sur une touche pour récupérer le contenu précédent du presse papier.") + proc.stdin.write(old_clipboard) + proc.stdin.close() + proc.stdout.close() + def clipboard(texte): + saveclipboard() proc =subprocess.Popen(['xclip','-selection','clipboard'],\ stdin=subprocess.PIPE,stdout=sys.stdout,stderr=sys.stderr) proc.stdin.write(texte) @@ -409,4 +426,6 @@ if __name__ == "__main__": parser.print_help() else: parsed.action(parsed.fname) + + saveclipboard(restore=True) -- GitLab