From f2373a325af49302930fcde1fdc4566d14e7f1f3 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Mon, 21 Dec 2020 21:07:14 +0100 Subject: [PATCH] Allow to source local config file --- ecran | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ecran b/ecran index 17d53e5..319bc5a 100755 --- a/ecran +++ b/ecran @@ -53,6 +53,10 @@ The second output is: ${SECOND_OUTPUT_NAME}." fi ## }}} + [ -f "${HOME}/.config/xrandr.conf" ] && \ + . "${HOME}/.config/xrandr.conf" && \ + printf "%b\n" 'Use local config file.' + } # }}} get_primary_output_name() { # {{{ @@ -131,7 +135,11 @@ define_vars case "${1}" in primary | off ) ## TODO : One command to enable primary screen and a loop to disable all other connected output - xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then + xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}" + else + xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + fi if [ -n "${SECOND_OUTPUT_NAME}" ]; then xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off ; fi printf "%b\n" 'Enable only primary output' ;; @@ -141,11 +149,19 @@ case "${1}" in printf "%b\n" 'Xrandr for second output left-of primary screen' ;; rightof | right-of | home ) - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}" + else + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + fi printf "%b\n" 'Xrandr for second output left-of primary screen' ;; above ) - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}" + else + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto + fi printf "%b\n" 'Xrandr for second output above primary screen' ;; out | game | second )