Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion autorandr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# and saving/loading the current configuration are adjusted accordingly.

XRANDR=/usr/bin/xrandr
#XRANDR=debug_xrandr
DISPER=/usr/bin/disper
XDPYINFO=/usr/bin/xdpyinfo
PROFILES=~/.autorandr/
Expand Down Expand Up @@ -166,8 +167,35 @@ config_equal() {
fi
}

debug_xrandr() {
echo "DEBUG: calling xrandr $@"
xrandr "$@"
}

load_cfg_xrandr() {
sed 's!^!--!' "$1" | xargs $XRANDR
#it's not possible to turn off LVDS1 and turn on HDMI1 in one command. It
# should be splitted to per-display commands

OPTIONS=$(
awk ' /^output/ { print ARGS; ARGS=""; }

END { print ARGS; ARGS=""; }

{ ARGS=ARGS" --"$0; }
' < "$1")

#first - options which turn off displays
{
echo "$OPTIONS" | grep -- "--off";
echo "$OPTIONS" | grep -v -- "--off"
} | while read LINE;do
if [ -n "$LINE" ];then
$XRANDR $LINE;
fi
done


# sed 's!^!--!' "$1" | xargs $XRANDR
}

load_cfg_disper() {
Expand All @@ -179,6 +207,7 @@ load() {
local CONF="$PROFILES/$PROFILE/config"
if [ -e "$CONF" ] ; then
echo " -> loading profile $PROFILE"
#echo "DEBUG: LOAD_METHOD=$LOAD_METHOD CONF=$CONF"
$LOAD_METHOD "$CONF"

[ -x "$PROFILES/$PROFILE/postswitch" ] && \
Expand Down