| |
@@ -663,12 +663,12 @@
|
| |
'-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(
|
| |
'',
|
| |
- '--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')
|
| |
@@ -846,30 +846,29 @@
|
| |
|
| |
[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
|
| |
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
|
| |
+ 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 %s" % selection,
|
| |
+ file=sys.stderr)
|
| |
|
| |
if ( not short_url and not options.rawurl ):
|
| |
print("WARNING: Could not shorten URL", file=sys.stderr)
|
| |
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.