I piped the output from xrandr to my second subprocess via its stdin.
Whenever you need to pipe data with Python, you will need to create two different subprocess instances. Resolution_string, junk = p2.communicate() P2 = subprocess.Popen(cmd2, stdin=p.stdout, stdout=subprocess.PIPE) P = subprocess.Popen(cmd, stdout=subprocess.PIPE) I then had to take that information and translate it into Python. I eventually found the following command: I wanted to find a way to get the screen resolution without installing a third party module. If you do a Google search, you’ll see people using various Python GUI toolkits. There are several ways to get your screen resolution in Linux. Let’s get started! Using the Linux Command Line
Not all of the solutions will be cross-platform, but I’ll be sure to mention that fact when I discuss those methods. In this article, we’ll look at some of the ways to get your screen resolution. I was recently looking into ways to get my screen resolution with Python to help diagnose an issue with an application that wasn’t behaving correctly.