Mon 06 Jul 2020 08:30:14 AM UTC

Faking your resolution for screen-casts or screenshots

The set up

I’ve got a really cheap laptop. I’ve also got a i7 Lenovo x230 powerhouse. They both have a screen resolution of 1366x768, which I usually don’t mind too much, unless I want to make a screen-cast or take a screenshot of a really detailed logic analyzer capture or something.

Now, I could plug into my 4K TV or 1080p monitor, but getting off the couch just to take a screenshot? No, there’s a better way..

Using xrandr we can “fake” it, telling X to give us whatever resolution we want while “zooming” in or out to make it all fit on our screen. Of course, it looks like crap on the screen, but we can take nice and crisp screenshots or casts as if we had a 1080p or even 4K monitor hooked up.

How-To

So, here’s how I get xrandr to give me a “1080p” display:

xrandr --output eDP1 --mode 1366x768 --panning 1920x1080 --scale 1.405x1.406

Note that if your physical resolution is not 1366x768, then you’ll need to adjust this command. Here’s the break down:

--output eDP1
This tells xrandr which physical monitor you want to play around with. Check the output of xrandr to figure out what yours is.
--mode 1366x768
Here we're telling xrandr the physical resolution we want to have. Set it to your monitor/screen's native resolution. Again, running xrandr without any arguments is your friend here.
--panning 1920x1080
Now it gets interesting. Here, we tell xrandr to go ahead and give us a 1080p screen, allowing us to pan around with the mouse if needed.
--scale 1.405x1.406
Finally, we tell xrandr to scale the virtual screen so it fits into our native resolution just right, negating any need for panning. Note that this last part is just the ratio of what you chose for --mode and --panning for both the X and Y dimensions.

Setting it back to normal is also pretty straight forward:

xrandr --output eDP1 --mode 1366x768 --panning 1366x768 --scale 1x1

Here I just set –mode and –panning both to the monitors native resolution and set scale to 1x1, or no scaling. Again, make sure you use your screens native resolution, not mine.

So, all that’s left is to wrap these up in a nice shell script or aliases, but I’ll leave that as an exercise to the reader..