1 [[!meta title="Autorandr: automatically adjust screen layout"]]
3 Like many laptop users, I often plug my laptop into different monitor
4 setups (multiple monitors at my desk, projector when presenting, etc.)
5 Running xrandr commands or clicking through interfaces gets tedious,
6 and writing scripts isn't much better.
9 across [autorandr](https://github.com/phillipberndt/autorandr), which
10 detects attached monitors using EDID (and other settings), saves
11 xrandr configurations, and restores them. It can also run arbitrary
12 scripts when a particular configuration is loaded. I've packed it, and
13 it is currently waiting in NEW. If you can't wait,
15 [deb is here](https://www.donarmstrong.com/autorandr_1.2-1_all.deb)
18 [git repo is here](https://git.donarmstrong.com/deb_pkgs/autorandr.git).
20 To use it, simply install the package, and create your initial
21 configuration (in my case, undocked):
24 autorandr --save undocked
27 then, dock your laptop (or plug in your external monitor(s)), change
28 the configuration using xrandr (or whatever you use), and save your
29 new configuration (in my case, workstation):
32 autorandr --save workstation
35 repeat for any additional configurations you have (or as you find new
38 Autorandr has `udev`, `systemd`, and `pm-utils` hooks, and `autorandr
39 --change` should be run any time that new displays appear. You can
40 also run `autorandr --change` or `autorandr --load workstation`
41 manually too if you need to. You can also add your own
42 '~/.config/autorandr/$PROFILE/postswitch` script to run after a
43 configuration is loaded. Since I run i3, my workstation configuration
50 xrandr --output DP2-2 --primary
51 i3-msg '[workspace="^(1|4|6)"] move workspace to output DP2-2;'
52 i3-msg '[workspace="^(2|5|9)"] move workspace to output DP2-3;'
53 i3-msg '[workspace="^(3|8)"] move workspace to output DP2-1;'
56 which fixes the dpi appropriately, sets the primary screen (possibly
57 not needed?), and moves the i3 workspaces about. You can also arrange
58 for configurations to never be run by adding a `block` hook in the
61 Check it out if you change your monitor configuration regularly!