Avatar Hund

Linux, plaintext & minimalism

March 25, 2019

How to fake a dual monitor setup using xrandr

A completely random but very friendly user named Elodin from the IRC-channel #i3 on the freenode network wrote a Python script for me. It’s a script that lets you fake an dual monitor setup on a single monitor setup. And it has been working really good for me so far!

It uses xrandr for the magic, the official configuration utility to the RandR. It’s a CLI-tool that can be used to set things like the size, orientation or the reflection of the outputs for a monitor.

A screenshot showing my fake dual monitor setup using xrandr
A screenshot showing my fake dual monitor setup using xrandr

If you’re thinking “Why?”, I suggest you reading my previous post: “I went from a multi monitor setup to just a single monitor setup”.

This is only tested with the i3 window manager, but it should (in theory) work with other window managers. If you try it with something else let me know how it went. :)

The script

The script is a little more than 150 lines of code so I uploaded it to my git repo here. Download it and make it executable with $ chmod +x mon.py.

Usage

Splitting the monitor

To split your monitor with the same ratio as seen in the screenshot:

$ ./mon.py split -r 70x30

If you don’t specify a value it should default to 50x50.

Available flags

-h, --help Show the help message
--i3ipc If you wish to put the focus back on the workspace where you where when you ran the script. This requires the Python-package i3ipc which is available via pip: pip install --user i3ipc.
--i3 Use this flag if you use i3 in order to reload the panels after splitting the monitor.
--reload It’s also possible to pass your own commands like --reload i3-msg reload.

Reverting back to one monitor

To revert back to a single monitor setup:

$ ./mon.py undo
Tags: RandR | xrandr | Scripts | Utils

Feedback