Skip to content

Commit

Permalink
Merge pull request #36 from Wolfizen/patch-1
Browse files Browse the repository at this point in the history
Fix xrandr subprocess output capture for newer Python/xrandr versions
  • Loading branch information
koiuo authored Feb 10, 2024
2 parents 0740cb9 + c5f66d4 commit cef73ee
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions randrctl/xrandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ def _xrandr(self, *args):
logger.debug("Calling xrandr with args %s", args)
args.insert(0, self.EXECUTABLE)

p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, env=self.env)
err = p.stderr.readlines()
p = subprocess.run(args, capture_output=True, shell=False, env=self.env)
err = p.stderr
if err:
# close descriptors
p.stderr.close()
p.stdout.close()
err_str = ''.join(map(lambda x: x.decode(), err)).strip()
err_str = err.decode()
raise XrandrException(err_str, args)
out = list(map(lambda x: x.decode(), p.stdout.readlines()))
out = list(map(lambda x: x.decode(), p.stdout.splitlines()))
if out:
out.pop(0) # remove first line. It describes Screen
return out
Expand Down

0 comments on commit cef73ee

Please sign in to comment.