()
| 156 | |
| 157 | |
| 158 | def init_xclip_clipboard(): |
| 159 | DEFAULT_SELECTION='c' |
| 160 | PRIMARY_SELECTION='p' |
| 161 | |
| 162 | def copy_xclip(text, primary=False): |
| 163 | text = _PYTHON_STR_TYPE(text) # Converts non-str values to str. |
| 164 | selection=DEFAULT_SELECTION |
| 165 | if primary: |
| 166 | selection=PRIMARY_SELECTION |
| 167 | p = subprocess.Popen(['xclip', '-selection', selection], |
| 168 | stdin=subprocess.PIPE, close_fds=True) |
| 169 | p.communicate(input=text.encode(ENCODING)) |
| 170 | |
| 171 | def paste_xclip(primary=False): |
| 172 | selection=DEFAULT_SELECTION |
| 173 | if primary: |
| 174 | selection=PRIMARY_SELECTION |
| 175 | p = subprocess.Popen(['xclip', '-selection', selection, '-o'], |
| 176 | stdout=subprocess.PIPE, |
| 177 | stderr=subprocess.PIPE, |
| 178 | close_fds=True) |
| 179 | stdout, stderr = p.communicate() |
| 180 | # Intentionally ignore extraneous output on stderr when clipboard is empty |
| 181 | return stdout.decode(ENCODING) |
| 182 | |
| 183 | return copy_xclip, paste_xclip |
| 184 | |
| 185 | |
| 186 | def init_xsel_clipboard(): |
no outgoing calls
no test coverage detected
searching dependent graphs…