Implement clicking on URLs to open them

This commit is contained in:
Kovid Goyal
2016-12-01 16:03:32 +05:30
parent a05b64f2fe
commit 63f8fd5929
6 changed files with 100 additions and 35 deletions
+10
View File
@@ -5,6 +5,7 @@
import re
import os
import signal
import shlex
import subprocess
import ctypes
from collections import namedtuple
@@ -270,3 +271,12 @@ def set_primary_selection(text):
p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE)
p.stdin.write(text), p.stdin.close()
p.wait()
def open_url(url, program='default'):
if program == 'default':
cmd = ['xdg-open']
else:
cmd = shlex.split(program)
cmd.append(url)
subprocess.Popen(cmd).wait()