copywin - Linux


copywin is a command-line tool that allows users to copy the contents of a given window to the clipboard. It’s particularly useful when working with graphical applications where standard methods of text selection are not available.




  • WINDOW_ID is the ID of the window whose contents you want to copy. Use xwininfo -id to determine the window ID.
  • TEXT is an optional argument specifying the portion of text to copy within the window.


  • -a: Copy all text in the entire window.
  • -i: Ignore case when matching text (with -t).
  • -r: Copy text in a rectangular region.
  • -t: Copy text matching the specified regular expression.
  • -v: Print additional information, such as the copied text and window ID.
  • -h: Display help information.


Simple copy:

copywin 35818912

Copy rectangular region:

copywin -r 35818912 50,50 100,100

Copy text matching a regular expression:

copywin -t 35818912 "^This is the text I want\S*"

Common Issues

  • No output: Ensure that the window you’re targeting is focused and has visible text.
  • Incorrect text copied: Check the regular expression (if used) and try different matching options, such as -a or -i.
  • Permission denied: You may need to run copywin with elevated privileges (e.g., as root) if the target application has restricted access.


Copywin can be integrated with other commands to automate tasks. For example:

  • To copy text from a specific window and save it to a file:
copywin 35818912 | tee output.txt

Related Commands

  • xwininfo: Provides information about the current window, including its ID.
  • xclip: A clipboard manager that can interact with copywin to manipulate clipboard data.
  • grep: A text search tool that can be used to filter copied text before or after copying.