()
| 194 | |
| 195 | |
| 196 | def init_xsel_clipboard(): |
| 197 | DEFAULT_SELECTION = "-b" |
| 198 | PRIMARY_SELECTION = "-p" |
| 199 | |
| 200 | def copy_xsel(text, primary=False): |
| 201 | text = _stringifyText(text) # Converts non-str values to str. |
| 202 | selection_flag = DEFAULT_SELECTION |
| 203 | if primary: |
| 204 | selection_flag = PRIMARY_SELECTION |
| 205 | with subprocess.Popen( |
| 206 | ["xsel", selection_flag, "-i"], stdin=subprocess.PIPE, close_fds=True |
| 207 | ) as p: |
| 208 | p.communicate(input=text.encode(ENCODING)) |
| 209 | |
| 210 | def paste_xsel(primary=False): |
| 211 | selection_flag = DEFAULT_SELECTION |
| 212 | if primary: |
| 213 | selection_flag = PRIMARY_SELECTION |
| 214 | with subprocess.Popen( |
| 215 | ["xsel", selection_flag, "-o"], stdout=subprocess.PIPE, close_fds=True |
| 216 | ) as p: |
| 217 | stdout = p.communicate()[0] |
| 218 | return stdout.decode(ENCODING) |
| 219 | |
| 220 | return copy_xsel, paste_xsel |
| 221 | |
| 222 | |
| 223 | def init_wl_clipboard(): |
no outgoing calls
no test coverage detected