Fix: Only one xrandr command by action

This commit is contained in:
gardouille 2024-03-27 08:13:02 +01:00
parent fc144471a7
commit 07865b0013
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

24
ecran
View File

@ -155,37 +155,21 @@ define_vars
case "${1}" in case "${1}" in
primary | off ) primary | off )
## TODO: One command to enable primary screen and a loop to disable all other connected output ## 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}
xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode}
else
xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" ${primary_output_mode}
fi
if [ -n "${SECOND_OUTPUT_NAME}" ]; then xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off ; fi if [ -n "${SECOND_OUTPUT_NAME}" ]; then xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off ; fi
printf "%b\n" 'Enable only primary output' printf "%b\n" 'Enable only primary output'
;; ;;
leftof | left-of | ds | dock | dockstation | work ) 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 #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}
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
printf "%b\n" 'Xrandr for second output left-of primary screen' printf "%b\n" 'Xrandr for second output left-of primary screen'
;; ;;
rightof | right-of | home ) 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}
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
printf "%b\n" 'Xrandr for second output left-of primary screen' printf "%b\n" 'Xrandr for second output left-of primary screen'
;; ;;
above ) 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}
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
printf "%b\n" 'Xrandr for second output above primary screen' printf "%b\n" 'Xrandr for second output above primary screen'
;; ;;
out | game | second ) out | game | second )