]> oss.titaniummirror.com Git - displayset.git/commitdiff
Initial commit
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 17 Jan 2013 16:51:59 +0000 (09:51 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 17 Jan 2013 16:51:59 +0000 (09:51 -0700)
.gitignore [new file with mode: 0644]
README [new file with mode: 0644]
displayset [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..1377554
--- /dev/null
@@ -0,0 +1 @@
+*.swp
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..98bab64
--- /dev/null
+++ b/README
@@ -0,0 +1,10 @@
+displayset is a script that provides a useful transition between LCD panel and
+dual external monitors.  The script is currently configured for the Lenovo
+Thinkpad X201 and two 4:3 1600x1200 external LCD monitors.
+
+To tie into XFCE, create two new keyboard shortcuts:
+
+<super>l -> /usr/local/bin/displayset lcd
+<super>d -> /usr/local/bin/displayset dualext
+
+Read comments in the displayset script for more information
diff --git a/displayset b/displayset
new file mode 100755 (executable)
index 0000000..4cd8dd6
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+# displayset.sh [lcd|dualext]
+#
+# After issuing displayset.sh lcd:
+# - The LCD panel is turned on and both external monitors are turned off
+# - All windows are maximized and have no title bar, to maximize real estate
+# - All non-dialog new windows will become maximized
+#
+# After issuing displayset.sh dualext:
+# - The LCD panel is turned off and both external monitors are turned on
+# - All windows are unmaximized
+# - New windows will start normally, not maximized
+#
+# Window positions on the dual external monitors are not retained when switching
+# to lcd and back to dualext.  Specifically, the windows all end up on the
+# primary external display.
+
+# Change these settings according to the display configuration
+LCD=LVDS1
+LCD_MODE=1280x800
+EXT1=HDMI1
+EXT1_MODE=1600x1200
+EXT1_POS=1600x0
+EXT2=VGA1
+EXT2_MODE=1600x1200
+EXT2_POS=0x0
+
+winlist()
+{
+  wmctrl -l | sed -e 's/^\(0x[0-9a-f]*\) .*$/\1/'
+}
+
+maximus_no_maximize()
+{
+  # Setting undecorate to true will cause the window manager to eventually
+  # minimize all windows asynchronously, with little way for the script to know
+  # when all of that is done to restore the windows with wmctrl -k off.  The
+  # solution is to leave /apps/maximus/undecorate always set to true.
+  gconftool -t bool -s /apps/maximus/no_maximize $1
+}
+
+current_maximize()
+{
+  for win in $(winlist); do
+    wmctrl -i -r $win -b add,maximized_vert,maximized_horz
+  done
+}
+
+current_unmaximize()
+{
+  for win in $(winlist); do
+    wmctrl -i -r $win -b remove,maximized_vert,maximized_horz
+  done
+}
+
+lcd()
+{
+  # Turn off one of the external monitors first so the LCD can come on.  The
+  # graphics card will ony support two output devices at a time.
+  xrandr --output $EXT1 --off
+  xrandr --output $EXT1 --off --output $EXT2 --off --output DP1 --off \
+        --output $LCD --mode $LCD_MODE --pos 0x0 --rotate normal
+
+  maximus_no_maximize false
+  current_maximize
+}
+
+dualext()
+{
+  # Turn off the LCD before turning on the second external monitor.  The
+  # graphics card will ony support two output devices at a time.
+  xrandr --output $EXT1 --mode $EXT1_MODE --pos $EXT1_POS --rotate normal
+  xrandr --output $LCD --off --output DP1 --off
+  xrandr --output $EXT1 --mode $EXT1_MODE --pos $EXT1_POS --rotate normal \
+        --output $LCD --off --output DP1 --off \
+        --output $EXT2 --mode $EXT2_MODE --pos $EXT2_POS --rotate normal
+
+  maximus_no_maximize true
+  current_unmaximize
+}
+
+# MAIN
+
+if [ "$1" = "lcd" ]; then
+  lcd
+elif [ "$1" = "dualext" ]; then
+  dualext
+else
+  echo "usage: $0 [lcd|dualext]" >&2
+  exit 1
+fi