()
| 209 | |
| 210 | |
| 211 | def init_wl_clipboard(): |
| 212 | PRIMARY_SELECTION = "-p" |
| 213 | |
| 214 | def copy_wl(text, primary=False): |
| 215 | text = _PYTHON_STR_TYPE(text) # Converts non-str values to str. |
| 216 | args = ["wl-copy"] |
| 217 | if primary: |
| 218 | args.append(PRIMARY_SELECTION) |
| 219 | if not text: |
| 220 | args.append('--clear') |
| 221 | subprocess.check_call(args, close_fds=True) |
| 222 | else: |
| 223 | pass |
| 224 | p = subprocess.Popen(args, stdin=subprocess.PIPE, close_fds=True) |
| 225 | p.communicate(input=text.encode(ENCODING)) |
| 226 | |
| 227 | def paste_wl(primary=False): |
| 228 | args = ["wl-paste", "-n", "-t", "text"] |
| 229 | if primary: |
| 230 | args.append(PRIMARY_SELECTION) |
| 231 | p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) |
| 232 | stdout, _stderr = p.communicate() |
| 233 | return stdout.decode(ENCODING) |
| 234 | |
| 235 | return copy_wl, paste_wl |
| 236 | |
| 237 | |
| 238 | def init_klipper_clipboard(): |
no outgoing calls
no test coverage detected
searching dependent graphs…