Skip to content

Commit

Permalink
Use Qt5 if GTK isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
akkana committed May 25, 2017
1 parent 6583d19 commit a01e7e8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pyclip
@@ -1,14 +1,21 @@
#!/usr/bin/env python2
#!/usr/bin/env python

import gtk
import re

primary = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
try:
import gtk

if not primary.wait_is_text_available() :
sys.exit(0)
primary = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
if not primary.wait_is_text_available() :
sys.exit(0)
s = primary.wait_for_text()

s = primary.wait_for_text()
except:
from PyQt5.QtCore import QApplication

qc = QApplication.clipboard()
s = qc.text(c.Selection)
# Use qc.Clipboard if you want the clipboard selection

# If it's a LinkedIn URL, fix their stupid errors:
if re.search('(www\.)*linkedin.com/', s, flags=re.IGNORECASE):
Expand Down

0 comments on commit a01e7e8

Please sign in to comment.