dont crash if a picture is in the clipboard
This commit is contained in:
parent
76ba0104d5
commit
452ae6015f
13
offpunk.py
13
offpunk.py
|
@ -2628,11 +2628,14 @@ Use with "cache" to copy the path of the cached content."""
|
||||||
if shutil.which('xsel'):
|
if shutil.which('xsel'):
|
||||||
clipboards = []
|
clipboards = []
|
||||||
urls = []
|
urls = []
|
||||||
clipboards.append(subprocess.check_output(['xsel','-p'],text=True))
|
for selec in ["-p","-s","-b"]:
|
||||||
clipboards.append(subprocess.check_output(['xsel','-s'],text=True))
|
try:
|
||||||
clipboards.append(subprocess.check_output(['xsel','-b'],text=True))
|
clipboards.append(subprocess.check_output(['xsel',selec],text=True))
|
||||||
|
except Exception as err:
|
||||||
|
#print("Skippink clipboard %s because %s"%(selec,err))
|
||||||
|
pass
|
||||||
for u in clipboards:
|
for u in clipboards:
|
||||||
if looks_like_url(u) :
|
if "://" in u and looks_like_url(u) and u not in urls :
|
||||||
urls.append(u)
|
urls.append(u)
|
||||||
if len(urls) > 1:
|
if len(urls) > 1:
|
||||||
self.lookup = []
|
self.lookup = []
|
||||||
|
@ -2643,7 +2646,7 @@ Use with "cache" to copy the path of the cached content."""
|
||||||
elif len(urls) == 1:
|
elif len(urls) == 1:
|
||||||
self.do_go(urls[0])
|
self.do_go(urls[0])
|
||||||
else:
|
else:
|
||||||
print("Go where? (hint: simply copy an URL)")
|
print("Go where? (hint: simply copy an URL in your clipboard)")
|
||||||
else:
|
else:
|
||||||
print("Go where? (hint: install xsel to go to copied URLs)")
|
print("Go where? (hint: install xsel to go to copied URLs)")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue