Dont use xsel on OS X
This commit is contained in:
parent
8ed7bdc42f
commit
1cdd481e00
@ -6,6 +6,7 @@ import os
|
|||||||
import threading
|
import threading
|
||||||
import pwd
|
import pwd
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import sys
|
||||||
from collections import namedtuple, defaultdict
|
from collections import namedtuple, defaultdict
|
||||||
|
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
@ -16,6 +17,10 @@ from .fast_data_types import (
|
|||||||
appname = 'kitty'
|
appname = 'kitty'
|
||||||
version = (0, 1, 0)
|
version = (0, 1, 0)
|
||||||
str_version = '.'.join(map(str, version))
|
str_version = '.'.join(map(str, version))
|
||||||
|
_plat = sys.platform.lower()
|
||||||
|
isosx = 'darwin' in _plat
|
||||||
|
|
||||||
|
|
||||||
ScreenGeometry = namedtuple('ScreenGeometry', 'xstart ystart xnum ynum dx dy')
|
ScreenGeometry = namedtuple('ScreenGeometry', 'xstart ystart xnum ynum dx dy')
|
||||||
WindowGeometry = namedtuple('WindowGeometry', 'left top right bottom xnum ynum')
|
WindowGeometry = namedtuple('WindowGeometry', 'left top right bottom xnum ynum')
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ from contextlib import contextmanager
|
|||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
|
||||||
|
from .constants import isosx
|
||||||
from .fast_data_types import glfw_get_physical_dpi
|
from .fast_data_types import glfw_get_physical_dpi
|
||||||
|
|
||||||
libc = ctypes.CDLL(None)
|
libc = ctypes.CDLL(None)
|
||||||
@ -264,12 +265,16 @@ def handle_unix_signals():
|
|||||||
|
|
||||||
|
|
||||||
def get_primary_selection():
|
def get_primary_selection():
|
||||||
|
if isosx:
|
||||||
|
return '' # There is no primary selection on OS X
|
||||||
# glfw has no way to get the primary selection
|
# glfw has no way to get the primary selection
|
||||||
# https://github.com/glfw/glfw/issues/894
|
# https://github.com/glfw/glfw/issues/894
|
||||||
return subprocess.check_output(['xsel', '-p']).decode('utf-8')
|
return subprocess.check_output(['xsel', '-p']).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def set_primary_selection(text):
|
def set_primary_selection(text):
|
||||||
|
if isosx:
|
||||||
|
return # There is no primary selection on OS X
|
||||||
if isinstance(text, str):
|
if isinstance(text, str):
|
||||||
text = text.encode('utf-8')
|
text = text.encode('utf-8')
|
||||||
p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE)
|
p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE)
|
||||||
@ -279,7 +284,7 @@ def set_primary_selection(text):
|
|||||||
|
|
||||||
def open_url(url, program='default'):
|
def open_url(url, program='default'):
|
||||||
if program == 'default':
|
if program == 'default':
|
||||||
cmd = ['xdg-open']
|
cmd = ['open'] if isosx else ['xdg-open']
|
||||||
else:
|
else:
|
||||||
cmd = shlex.split(program)
|
cmd = shlex.split(program)
|
||||||
cmd.append(url)
|
cmd.append(url)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user