From 7a9c5c4aea930a229657c057b762e47c1643ab41 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Nov 2009 17:52:02 +0100 Subject: [PATCH] add script to automatically detect and enable the right monitors on the right place Signed-off-by: Nico Schottelius --- x-monitors.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 x-monitors.sh diff --git a/x-monitors.sh b/x-monitors.sh new file mode 100755 index 0000000..0daa927 --- /dev/null +++ b/x-monitors.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# 2009 Nico Schottelius (nico-nsbin at schottelius.org) +# +# This file is part of nsbin. +# +# nsbin is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# nsbin is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with nsbin. If not, see . +# +# +# Automatically manage connected and disconnected external monitors with xrandr +# +# Add your main monitor to ~/.x-monitors-main (i.e. the laptop screen), +# and add all possible other monitors in the positions files +# ~/.x-monitors-{left-of right-of above below}. +# +# +# + +################################################################################ +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 +done