Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/pyperclip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ def paste_qt():
return copy_qt, paste_qt


def init_xclip_clipboard():
def init_xclip_clipboard(primary=False):
DEFAULT_SELECTION='c'
PRIMARY_SELECTION='p'

def copy_xclip(text, primary=False):
def copy_xclip(text, primary=primary):
text = _stringifyText(text) # Converts non-str values to str.
selection=DEFAULT_SELECTION
if primary:
Expand All @@ -204,7 +204,7 @@ def copy_xclip(text, primary=False):
stdin=subprocess.PIPE, close_fds=True)
p.communicate(input=text.encode(ENCODING))

def paste_xclip(primary=False):
def paste_xclip(primary=primary):
selection=DEFAULT_SELECTION
if primary:
selection=PRIMARY_SELECTION
Expand All @@ -219,11 +219,11 @@ def paste_xclip(primary=False):
return copy_xclip, paste_xclip


def init_xsel_clipboard():
def init_xsel_clipboard(primary=False):
DEFAULT_SELECTION='-b'
PRIMARY_SELECTION='-p'

def copy_xsel(text, primary=False):
def copy_xsel(text, primary=primary):
text = _stringifyText(text) # Converts non-str values to str.
selection_flag = DEFAULT_SELECTION
if primary:
Expand All @@ -232,7 +232,7 @@ def copy_xsel(text, primary=False):
stdin=subprocess.PIPE, close_fds=True)
p.communicate(input=text.encode(ENCODING))

def paste_xsel(primary=False):
def paste_xsel(primary=primary):
selection_flag = DEFAULT_SELECTION
if primary:
selection_flag = PRIMARY_SELECTION
Expand Down Expand Up @@ -485,7 +485,7 @@ def paste_wsl():


# Automatic detection of clipboard mechanisms and importing is done in deteremine_clipboard():
def determine_clipboard():
def determine_clipboard(primary=False):
'''
Determine the OS/platform and set the copy() and paste() functions
accordingly.
Expand Down Expand Up @@ -530,9 +530,9 @@ def determine_clipboard():
return init_gtk_clipboard()

if _executable_exists("xsel"):
return init_xsel_clipboard()
return init_xsel_clipboard(primary)
if _executable_exists("xclip"):
return init_xclip_clipboard()
return init_xclip_clipboard(primary)
if _executable_exists("klipper") and _executable_exists("qdbus"):
return init_klipper_clipboard()

Expand Down