Commit da47c366 authored by Nico Schottelius's avatar Nico Schottelius

run x-monitors twice

Signed-off-by: default avatarNico Schottelius <nico@ikn.schottelius.org>
parent 7a9c5c4a
......@@ -32,12 +32,22 @@ main="$(cat ~/.x-monitors-main)"
positions="left-of right-of above below"
prefix=".x-monitors-"
# search for all possible monitors in all positions
for position in $positions; do
posfile="${HOME}/${prefix}${position}"
if [ -f "${posfile}" ]; then
while read output; do
xrandr --output "${output}" --${position} "${main}" --auto
done < "${posfile}"
fi
i=0
# Needs to run twice: xrandr may not be able to
# enable a newly connected monitor, because a disconnected one
# is still enabled. The first runs disables disconnected monitors, the
# second one enables all connected ones.
while [ "${i}" -lt 2 ]; do
# search for all possible monitors in all positions
for position in $positions; do
posfile="${HOME}/${prefix}${position}"
if [ -f "${posfile}" ]; then
while read output; do
xrandr --output "${output}" --${position} "${main}" --auto
done < "${posfile}"
fi
done
i=$(($i+1))
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment