Try to guess second output name if not already set

This commit is contained in:
Jeremy Gardais 2020-10-23 11:20:09 +02:00
parent 1d51457092
commit 5e23ba15d1
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 13 additions and 13 deletions

24
ecran
View File

@ -43,15 +43,15 @@ define_vars() { # {{{
debug_message "define_vars \
The primary output is: ${PRIMARY_OUTPUT_NAME}."
## }}}
return_second_output_name="0"
SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${MAIN_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
## Second output {{{
### If the second output wasn't manually defined,
### try to get it's name
if [ -z "${SECOND_OUTPUT_NAME}" ]; then
SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${PRIMARY_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
debug_message "define_vars \
The second connected output is: ${SECOND_OUTPUT_NAME}."
return "${return_second_output_name}"
The second output is: ${SECOND_OUTPUT_NAME}."
fi
## }}}
}
# }}}
@ -130,10 +130,10 @@ define_vars
# This code can't be in a function due to arguments
case "${1}" in
primary | off )
## TODO: One command to enable main screen and a loop to disable all other connected output
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off --output VGA-1 --off --output HDMI-3 --off --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off
xrandr --output VGA --off
printf "%b\n" 'Desactivate all video output'
## 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 "${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