Script only has effect when i3 is restarted
I have the following last line in my .i3/config file:
exec_always --no-startup-id /home/will/etc/will-laptop/scripts/office-monitor-setup.sh
The script (below) just executes some xrandr stuff, but the modified resolutions don't take effect the first time i3 is started. If I restart i3 or execute the script from a command line, it seems to run just fine. I've tried removing the path with no effect. I've tried running it as exec i3-msg 'exec office-monitor-setup.sh'
with no effect. The i3 debugging output says that it's running the script and there's no error or anything. Any help?
office-monitor-setup.sh:
#!/bin/bash
Primary="HDMI1"
Secondary="VGA1"
Default="LVDS1"
if (xrandr | grep "$Primary connected"); then
xrandr --output $Primary --primary --mode 1920x1080 --refresh 60
xrandr --output $Default --off
if (xrandr | grep "$Secondary connected"); then
xrandr --output $Secondary --pos 1920x0 --mode 1600x1200 --refresh 60
fi
fi
nitrogen --restore