Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import os
  4. from subprocess import Popen, PIPE
  5.  
  6. proc = Popen(
  7. ["xsel", "-o", "-b"], stdout=PIPE
  8. )
  9. linesep = bytes(os.linesep, encoding="UTF-8")
  10. stdout, _ = proc.communicate()
  11. lines = stdout.split(linesep)
  12.  
  13. blen = 0
  14. out = []
  15.  
  16. if lines:
  17. for line in lines:
  18. blen = max(blen, len(line))
  19.  
  20. for line in lines:
  21. flen = blen - len(line)
  22. out.append(line + (b" " * flen))
  23.  
  24. proc = Popen(
  25. ["xsel", "-i", "-b"], stdin=PIPE
  26. )
  27. proc.communicate(linesep.join(out))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement