Manage second output position with variable

This commit is contained in:
gardouille 2024-03-28 11:19:41 +01:00
parent c3956e1305
commit ccd4166e10
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

26
ecran
View File

@ -22,7 +22,7 @@ readonly COLOR_DEBUG="${PURPLE}"
readonly PRIMARY_OUTPUT_MODE="--auto"
readonly SECOND_OUTPUT_MODE="--auto"
readonly SECOND_OUTPUT_ACTION="NONE"
# }}}
debug_message() { # {{{
@ -77,6 +77,14 @@ The second output is: ${SECOND_OUTPUT_NAME}."
fi
## }}}
## Second output action {{{
### If second_output_action wasn't defined (by argument, ~/.config/xrandr.conf file, var env…)
### Use default value
### Then use ${second_output_action} variable without "" to be able to use it as xrandr's option
if [ -z "${second_output_action}" ]; then
second_output_action=${SECOND_OUTPUT_ACTION}
fi
## }}}
}
# }}}
get_primary_output_name() { # {{{
@ -160,17 +168,21 @@ case "${1}" in
printf "%b\n" 'Enable only primary output'
;;
leftof | left-of | ds | dock | dockstation | work )
second_output_action="--left-of"
#xrandr --output VGA-1 --mode 1024x768 --left-of "${PRIMARY_OUTPUT_NAME:-/dev/null}" --output "${PRIMARY_OUTPUT_NAME:-/dev/null}" --mode 1366x768
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'
xrandr --output "${SECOND_OUTPUT_NAME:-/dev/null}" ${second_output_mode} ${second_output_action} "${PRIMARY_OUTPUT_NAME:-/dev/null}" --output "${PRIMARY_OUTPUT_NAME:-/dev/null}" ${primary_output_mode}
printf "%b\n" "Xrandr - Manage second output position from primary output (option : \"${second_output_action}\")."
#printf "%b\n" "Xrandr for second output left-of (option : \"${second_output_action}\") primary screen"
;;
rightof | right-of | home )
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'
second_output_action="--right-of"
xrandr --output "${SECOND_OUTPUT_NAME:-/dev/null}" ${second_output_mode} ${second_output_action} "${PRIMARY_OUTPUT_NAME:-/dev/null}" --output "${PRIMARY_OUTPUT_NAME:-/dev/null}" ${primary_output_mode}
printf "%b\n" "Xrandr - Manage second output position from primary output (option : \"${second_output_action}\")."
;;
above )
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'
second_output_action="--above"
xrandr --output "${SECOND_OUTPUT_NAME:-/dev/null}" ${second_output_mode} ${second_output_action} "${PRIMARY_OUTPUT_NAME:-/dev/null}" --output "${PRIMARY_OUTPUT_NAME:-/dev/null}" ${primary_output_mode}
printf "%b\n" "Xrandr - Manage second output position from primary output (option : \"${second_output_action}\")."
;;
out | game | second )
xrandr --output "${SECOND_OUTPUT_NAME:-/dev/null}" ${second_output_mode} --output "${PRIMARY_OUTPUT_NAME:-/dev/null}" --off