From a9b6711228a39bc34fc817173de2627cf7b153c2 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 26 Sep 2020 18:50:29 -0400 Subject: [PATCH] Fix xcursorgen generating incorrect output to stdout --- win2xcur/writer/x11.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/win2xcur/writer/x11.py b/win2xcur/writer/x11.py index fa7405e..15d8085 100644 --- a/win2xcur/writer/x11.py +++ b/win2xcur/writer/x11.py @@ -40,10 +40,15 @@ def to_x11(frames: List[CursorFrame]) -> bytes: image.save(filename=os.path.join(png_dir, name)) counter += 1 - process = subprocess.Popen(['xcursorgen', '-p', png_dir], stdin=subprocess.PIPE, stdout=subprocess.PIPE) - result, error = process.communicate('\n'.join(configs).encode(sys.getfilesystemencoding())) + output_file = os.path.join(png_dir, 'cursor') + process = subprocess.Popen(['xcursorgen', '-p', png_dir, '-', output_file], stdin=subprocess.PIPE, + stderr=subprocess.PIPE) - if error: - raise RuntimeError('xcursorgen failed: %r' % error) + _, error = process.communicate('\n'.join(configs).encode(sys.getfilesystemencoding())) + if process.wait() != 0: + raise RuntimeError('xcursorgen failed: %r' % error) + + with open(output_file, 'rb') as f: + result = f.read() return result