# Path: lib/process.py
# def get_simple_cmd_output(cmd, stderr=STDOUT):
# def get_complex_cmd_output(cmd, stderr=STDOUT):
# def get_cmd_output_input_from_stdin(cmd, input_file):
# def get_return_code_of_simple_cmd(cmd, stderr=STDOUT):
# def get_exitcode_stdout_stderr(cmd):
# def execute_cmd(cmd):
# def execute_cmd_in_background(cmd):
# def get_process_list():
# def keep_alive(cmd):
# def is_process_running(pname):


    import os
    import sys
import subprocess
from lib import process

if __name__ == "__main__":
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))




def text_to_clipboards(text):
    """Copy text to both clipboards."""
    to_primary(text)
    to_clipboard(text)

#############################################################################

def to_primary(text):
    """Write text to 'primary'."""
    xsel_proc = subprocess.Popen(['xsel', '-pi'], stdin=subprocess.PIPE)
    xsel_proc.communicate(text.encode())


def to_clipboard(text):
    """Write text to 'clipboard'."""
    xsel_proc = subprocess.Popen(['xsel', '-bi'], stdin=subprocess.PIPE)
    xsel_proc.communicate(text.encode())

#############################################################################

def read_primary():
    """Read content of 'primary'."""
    cmd = 'xsel -po'

# Path: lib/process.py
# def get_simple_cmd_output(cmd, stderr=STDOUT):
# def get_complex_cmd_output(cmd, stderr=STDOUT):
# def get_cmd_output_input_from_stdin(cmd, input_file):
# def get_return_code_of_simple_cmd(cmd, stderr=STDOUT):
# def get_exitcode_stdout_stderr(cmd):
# def execute_cmd(cmd):
# def execute_cmd_in_background(cmd):
# def get_process_list():
# def keep_alive(cmd):
# def is_process_running(pname):


# Path: lib/clipboard.py
    import os
    import sys
import subprocess
from lib import process


if __name__ == "__main__":
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))




def text_to_clipboards(text):
    """Copy text to both clipboards."""
    to_primary(text)
    to_clipboard(text)

#############################################################################

def to_primary(text):
    """Write text to 'primary'."""
    xsel_proc = subprocess.Popen(['xsel', '-pi'], stdin=subprocess.PIPE)
    xsel_proc.communicate(text.encode())


def to_clipboard(text):
    """Write text to 'clipboard'."""
    xsel_proc = subprocess.Popen(['xsel', '-bi'], stdin=subprocess.PIPE)
    xsel_proc.communicate(text.encode())

#############################################################################

def read_primary():
    """Read content of 'primary'."""
    cmd = 'xsel -po'

    return process.get_simple_cmd_output(cmd)