From ec48e02381ed2a3a5fc991f035540caaa1c150fa Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Thu, 17 Jan 2013 09:51:59 -0700 Subject: [PATCH] Initial commit --- .gitignore | 1 + README | 10 ++++++ displayset | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100755 displayset diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/README b/README new file mode 100644 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: + +l -> /usr/local/bin/displayset lcd +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 index 0000000..4cd8dd6 --- /dev/null +++ b/displayset @@ -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 -- 2.39.2