From d083780d22604acdbbf87ede04a4958d2eb1d2e1 Mon Sep 17 00:00:00 2001 From: Farhaan Bukhsh(fhackdroid) Date: Jan 11 2017 14:10:40 +0000 Subject: [PATCH 1/3] Fix copying url to the clipboard Previously we were using primary clipboard as the only clipboard, now we just copy the url in all the clipboards available to xsel which is primary, secondary and clipboard. --- diff --git a/fpaste b/fpaste index 17cf770..364097b 100755 --- a/fpaste +++ b/fpaste @@ -846,30 +846,35 @@ Examples: [url, short_url] = paste(text, options) if url: - # try to save URL in clipboard, and warn but don't error + # Try to save URL in clipboard, and warn but don't throw error + copy_to_clipboard_status = False if options.clipout: if not os.access('/usr/bin/xsel', os.X_OK): print( 'OOPS - the clipboard options currently depend on "/usr/bin/xsel", which does not appear to be installed', file=sys.stderr) else: - xselcmd = 'xsel -i --%s' % options.selection - # os.popen(xselcmd, 'wb').write(url) - p = subprocess.Popen( - xselcmd, - shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - (out, err) = p.communicate(input=url.encode('utf-8')) - if p.returncode != 0: - if options.debug: - print(err, file=sys.stderr) - print( - "WARNING: URL not saved to clipboard", - file=sys.stderr) - else: - print("URL copied to primary clipboard") + # Copy the url in all the valid clipboard options + for selection in validClipboardSelectionOpts: + xselcmd = 'xsel -i --%s' % selection + # os.popen(xselcmd, 'wb').write(url) + p = subprocess.Popen( + xselcmd, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=subprocess.PIPE) + (out, err) = p.communicate(input=url.encode('utf-8')) + if p.returncode != 0: + if options.debug: + print(err, file=sys.stderr) + print( + "WARNING: URL not saved to clipboard", + file=sys.stderr) + copy_to_clipboard_status = True + + if not copy_to_clipboard_status: + print("URL copied to clipboards") if ( not short_url and not options.rawurl ): print("WARNING: Could not shorten URL", file=sys.stderr) From 1263591a17e8d398e0dd785656116851a1601226 Mon Sep 17 00:00:00 2001 From: Farhaan Bukhsh(fhackdroid) Date: Jan 19 2017 04:55:09 +0000 Subject: [PATCH 2/3] Update man page and help option --- diff --git a/docs/man/en/fpaste.1 b/docs/man/en/fpaste.1 index 53e80ad..755cdbd 100644 --- a/docs/man/en/fpaste.1 +++ b/docs/man/en/fpaste.1 @@ -40,7 +40,7 @@ return only the raw content URL; does not attempt to shorten the URL. Suitable read paste text from current X clipboard selection .TP \fB\-o, \-\-clipout\fR -save returned paste URL to X clipboard +save returned paste URL to all the clipboards i.e primary, secondary and clipboard .TP \fB\-\-selection=CLIPBOARD\fR specify which X clipboard to use. valid options: "primary" (default; middle\-mouse\-button paste), "secondary" (uncommon), or "clipboard" (ctrl\-v paste) diff --git a/fpaste b/fpaste index 364097b..8a4e4c5 100755 --- a/fpaste +++ b/fpaste @@ -663,7 +663,7 @@ Examples: '-o', '--clipout', dest='clipout', - help='save returned paste URL to X clipboard', + help='save returned paste URL to all available clipboards', action="store_true", default=False) fpasteProg_group.add_option( @@ -847,7 +847,6 @@ Examples: [url, short_url] = paste(text, options) if url: # Try to save URL in clipboard, and warn but don't throw error - copy_to_clipboard_status = False if options.clipout: if not os.access('/usr/bin/xsel', os.X_OK): print( @@ -857,7 +856,6 @@ Examples: # Copy the url in all the valid clipboard options for selection in validClipboardSelectionOpts: xselcmd = 'xsel -i --%s' % selection - # os.popen(xselcmd, 'wb').write(url) p = subprocess.Popen( xselcmd, shell=True, @@ -869,12 +867,8 @@ Examples: if options.debug: print(err, file=sys.stderr) print( - "WARNING: URL not saved to clipboard", + "WARNING: URL not saved to %s" % selection, file=sys.stderr) - copy_to_clipboard_status = True - - if not copy_to_clipboard_status: - print("URL copied to clipboards") if ( not short_url and not options.rawurl ): print("WARNING: Could not shorten URL", file=sys.stderr) From 82240dff7e5ba9dd5f3094b447052195add810b9 Mon Sep 17 00:00:00 2001 From: Farhaan Bukhsh(fhackdroid) Date: Jan 24 2017 04:20:50 +0000 Subject: [PATCH 3/3] Replace selection with input-selection Selection is being replaced by input selection which because now the clipboard selection option is only given for the input, the output or clipout option paste the working URL on all the keyboard. --- diff --git a/docs/man/en/fpaste.1 b/docs/man/en/fpaste.1 index 755cdbd..36c7eb5 100644 --- a/docs/man/en/fpaste.1 +++ b/docs/man/en/fpaste.1 @@ -42,7 +42,7 @@ read paste text from current X clipboard selection \fB\-o, \-\-clipout\fR save returned paste URL to all the clipboards i.e primary, secondary and clipboard .TP -\fB\-\-selection=CLIPBOARD\fR +\fB\-\-input\-selection=CLIPBOARD\fR specify which X clipboard to use. valid options: "primary" (default; middle\-mouse\-button paste), "secondary" (uncommon), or "clipboard" (ctrl\-v paste) .TP \fB\-\-fullpath\fR diff --git a/fpaste b/fpaste index 8a4e4c5..05c69ef 100755 --- a/fpaste +++ b/fpaste @@ -668,7 +668,7 @@ Examples: default=False) fpasteProg_group.add_option( '', - '--selection', + '--input-selection', dest='selection', help='specify which X clipboard to use. valid options: "primary" (default; middle-mouse-button paste), "secondary" (uncommon), or "clipboard" (ctrl-v paste)', metavar='CLIP')