12

I am using i3 as the window manager on my laptop. Now I want it to work with my HDMI monitor. So far I have this is my .3/config:

exec xrandr --output eDP1 --auto --output HDMI1 --auto --left-of eDP1

This works quite well but only as long as my HDMI monitor is plugged in. When it is not I have half of my workspaces not visible since they are not displayed on my laptops monitor.

How can I make it detect whether or not the other monitor is plugged in and have a configuration for both cases?
Also can it automatically detect when the HDMI is (un)plugged and change the configursation accordingly? Or do I have to bind it to a key to check for monitors?

danielspaniol
  • 365
  • 1
  • 5
  • 14

1 Answers1

12

Try this instead:

xrandr | grep 'HDMI1 connected' &&
    xrandr --output eDP1 --auto --output HDMI1 --auto --left-of eDP1

That will run the xrandr command only if the HMDI1 screen is connected. I don't know the details of the format of .3/config (although I do know it will ignore anything after the exec line, are you sure you want this with exec?), so if that doesn't work just put it in a script and call the script from config.

terdon
  • 98,183
  • 15
  • 197
  • 293