From 3fdfc79a1b7f8661feadf976eb2c1140c3596a69 Mon Sep 17 00:00:00 2001 From: Piotr Gabryjeluk Date: Wed, 28 Jan 2015 22:04:26 +0100 Subject: [PATCH 1/2] Added option to use arandr as config dumper --- auto-arandr | 1 + autorandr | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 120000 auto-arandr diff --git a/auto-arandr b/auto-arandr new file mode 120000 index 0000000..94cdea8 --- /dev/null +++ b/auto-arandr @@ -0,0 +1 @@ +autorandr \ No newline at end of file diff --git a/autorandr b/autorandr index c2c3384..10316c6 100755 --- a/autorandr +++ b/autorandr @@ -45,6 +45,7 @@ # and saving/loading the current configuration are adjusted accordingly. XRANDR=/usr/bin/xrandr +UNXRANDR=/usr/bin/unxrandr DISPER=/usr/bin/disper XDPYINFO=/usr/bin/xdpyinfo PROFILES=~/.autorandr/ @@ -60,6 +61,12 @@ CURRENT_CFG_METHOD="current_cfg_xrandr" LOAD_METHOD="load_cfg_xrandr" SCRIPTNAME="$(basename $0)" +# when called as auto-arandr, we'll use unxrandr for dumping current xrandr state +# unxrandr is a command line tool distributed along with arandr +if [ "$SCRIPTNAME" = "auto-arandr" ]; then + echo "Using arandr as config dump method..." >&2 + CURRENT_CFG_METHOD="current_cfg_arandr" +fi # when called as autodisper/auto-disper, we assume different defaults if [ "$SCRIPTNAME" = "auto-disper" ] || [ "$SCRIPTNAME" = "autodisper" ]; then echo "Assuming disper defaults..." >&2 @@ -113,6 +120,10 @@ setup_fp() { echo "$FP" } +current_cfg_arandr() { + unxrandr | sed -e 's/ --/\n/g' | tail -n +2 +} + current_cfg_xrandr() { local PRIMARY_SETUP=""; if [ -x "$XDPYINFO" ]; then From d39b651eacd8e687d4ebd2dd648cbf51980abcf8 Mon Sep 17 00:00:00 2001 From: Piotr Gabryjeluk Date: Wed, 28 Jan 2015 22:04:52 +0100 Subject: [PATCH 2/2] Added preswitch hooks in addition to postswitch ones --- autorandr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autorandr b/autorandr index 10316c6..174a5f1 100755 --- a/autorandr +++ b/autorandr @@ -189,6 +189,11 @@ load() { local PROFILE="$1" local CONF="$PROFILES/$PROFILE/config" if [ -e "$CONF" ] ; then + [ -x "$PROFILES/preswitch" ] && \ + "$PROFILES/preswitch" "$PROFILE" + [ -x "$PROFILES/$PROFILE/preswitch" ] && \ + "$PROFILES/$PROFILE/preswitch" "$PROFILE" + echo " -> loading profile $PROFILE" $LOAD_METHOD "$CONF"