On Sun, Jun 27, 2010 at 07:29:50PM -0400, "Benj. Mako Hill" <[email protected]> was
heard to say:
> <quote who="Daniel Burrows" date="Sun, Jun 27, 2010 at 08:52:16AM -0700">
> > The Chrome browser appears to read the X clipboard twice when you
> > paste a value, throwing away the first value it read. This makes it
> > difficult to use pwsafe with it. Obviously a fix in the browser is
> > ideal, but it would be nice in the meantime if pwsafe could get a "-2"
> > option that would copy each value to the clipboard twice (and I suspect
> > this patch is a lot easier to write and get applied than a patch for
> > Chrome).
> >
> > I have a patch for this worked up, but I'll need to clear it with my
> > employer before I can send it to you.
>
> Wonderful! Thanks I'll hold off on forwarding this upstream until I hear back
> about the patch.
OK, I've got a go-ahead; here's the patch.
Daniel
--- pwsafe.1.in.orig 2010-06-27 08:47:04.553650031 -0700
+++ pwsafe.1.in 2010-06-27 08:47:36.207490149 -0700
@@ -97,6 +97,9 @@
.B \-x, \-\-xclip
Force copying of username and password to X clipboard. This is selected by default if $DISPLAY is set.
.TP
+.B \-2, \-\-twice
+If the X clipboard is used, copy each element twice. This is useful to work against some clients (such as Google Chrome) which read from the clipboard twice.
+.TP
.B \-d, \-\-display=XDISPLAY
Override $DISPLAY. Implies \-\-xclip.
.TP
--- pwsafe.cpp.orig 2010-06-27 08:47:00.273928161 -0700
+++ pwsafe.cpp 2010-06-27 08:47:28.870872943 -0700
@@ -398,6 +398,7 @@
bool arg_username = false;
bool arg_password = false;
bool arg_details = false;
+bool twice = false;
int arg_verbose = 0;
int arg_debug = 0;
#ifndef X_DISPLAY_MISSING
@@ -440,6 +441,7 @@
{"display", required_argument, 0,'d'},
{"selection", required_argument, 0,'s'},
{"ignore", required_argument, 0,'G'},
+ {"twice", no_argument, 0, '2'},
#endif
// standard stuff
{"quiet", no_argument, 0, 'q'},
@@ -1159,6 +1161,7 @@
int c;
while ((c = getopt_long (argc, argv,
+ "2" // post username/password to the clipboard twice
"l" // long listing
"a" // add
"e" // edit
@@ -1308,6 +1311,9 @@
case 'h':
usage(false);
throw ExitEx(0);
+ case '2':
+ twice = true;
+ break;
case ':':
case '?':
// the message getopt() printed out is good enough
@@ -1343,6 +1349,7 @@
" -d, --display=XDISPLAY override $DISPLAY (implies -x)\n"
" -s, --selection={Primary,Secondary,Clipboard,Both} select the X selection effected (implies -x)\n"
" -G, --ignore=n...@host add n...@host to set of windows that don't receive the selection. Either NAME or @HOST can be omitted. (default is xclipboard, wmcliphist and klipper)\n"
+ " -2, --twice copy each value to the X selection twice\n"
#endif
" -q, --quiet print no extra information\n"
" -v, --verbose print more information (can be repeated)\n"
@@ -2655,9 +2662,13 @@
// this way if the notes contain a URL, the user can cut/paste that too
emit_notes(e.notes);
+ const int times = (!arg_echo && twice) ? 2 : 1;
+
if (username)
- ::emit(e.groupname(), "username", e.default_login?e.the_default_login:e.login);
+ for(int i = 0; i < times; ++i)
+ ::emit(e.groupname(), "username", e.default_login?e.the_default_login:e.login);
if (password)
+ for(int i = 0; i < times; ++i)
::emit(e.groupname(), "password", e.password);
if (arg_echo && arg_details)