From 07865b0013674e5b41eadc0bb9631d9c74667d5d Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 27 Mar 2024 08:13:02 +0100 Subject: [PATCH] Fix: Only one xrandr command by action --- ecran | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/ecran b/ecran index 06a2d34..c69806d 100755 --- a/ecran +++ b/ecran @@ -155,37 +155,21 @@ define_vars case "${1}" in primary | off ) ## TODO : One command to enable primary screen and a loop to disable all other connected output - if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then - xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - else - xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - fi + xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} if [ -n "${SECOND_OUTPUT_NAME}" ]; then xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off ; fi printf "%b\n" 'Enable only primary output' ;; leftof | left-of | ds | dock | dockstation | work ) #xrandr --output VGA-1 --mode 1024x768 --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode 1366x768 - if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - else - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - fi + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} printf "%b\n" 'Xrandr for second output left-of primary screen' ;; rightof | right-of | home ) - if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - else - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - fi + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} printf "%b\n" 'Xrandr for second output left-of primary screen' ;; above ) - if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - else - xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} - fi + xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode} printf "%b\n" 'Xrandr for second output above primary screen' ;; out | game | second )