Commits

Anonymous committed 1566212

It appear, some linux distribution don't have xsel. So check if xclip is
available.

  • Participants
  • Parent commits d2c89c3

Comments (0)

Files changed (1)

contrib/friendpastepy/friendpastepy.py

 # limitations under the License.
 
 import os
+import popen2
 import re
 import socket
 import sys
             data = os.popen("/usr/bin/pbpaste").read()
         else: # posix platform
             if os.environ.get('DISPLAY'):
-                try:
-                    data = os.popen("xsel").read()
-                except: 
-                    pass
-                    
+                ret = os.system("xsel > /dev/null")
+                if ret == 0:
+                     data = os.popen("xsel").read()
+                else:
+                    data = os.popen("xclip -o").read()                
+                
     if data is not None:
         return data
     raise ClipboardNotAvailable         
             return 0
         else:  # posix platform
             if os.environ.get('DISPLAY'):
-                try:
-                    data = re.escape(data)
-                    os.system("echo %s | xsel" % data)
-                except:
-                    pass
+                data = re.escape(data)
+                ret = os.system("echo %s | xsel" % data)
+                if ret != 0:
+                    os.system("echo %s | xclip -i" % data)
                 return 0
                                    
     raise ClipboardNotAvailable