Skip to content

Instantly share code, notes, and snippets.

@TheWaWaR
Created October 14, 2014 23:47
Show Gist options
  • Save TheWaWaR/f0fc672f9396515c9065 to your computer and use it in GitHub Desktop.
Save TheWaWaR/f0fc672f9396515c9065 to your computer and use it in GitHub Desktop.
Capture window by {xwd}
#!/usr/bin/env python
import os
import sys
def main(wid):
arg_dict = {'wid': wid}
CMD_XWD = 'xwd -id %(wid)d -out %(wid)d.xwd' % arg_dict
CMD_CONVERT = 'convert %(wid)d.xwd %(wid)d.png' % arg_dict
os.system('xwininfo -id %d' % wid)
print CMD_XWD
os.system(CMD_XWD)
print CMD_CONVERT
os.system(CMD_CONVERT)
if __name__ == '__main__':
main(int(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment