Update var name, comments and output messages

This commit is contained in:
gardouille 2020-10-23 11:17:12 +02:00
parent 6290ec2d0d
commit 1d51457092
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

47
ecran
View File

@ -12,9 +12,13 @@ readonly RED='\033[0;31m'
readonly RESET='\033[0m'
readonly COLOR_DEBUG="${PURPLE}"
## First and main screen (laptop screen,…)
## First and primary output (laptop screen, hdmi-1,…)
## It can be forced here or the script will try to discover it's name
#readonly MAIN_OUTPUT_NAME="LVDS-1"
#readonly PRIMARY_OUTPUT_NAME="LVDS-1"
## Second output (hdmi-2, dp-1,…)
## It can be forced here or the script will try to discover it's name
#readonly SECOND_OUTPUT_NAME
# }}}
@ -33,11 +37,11 @@ define_vars() { # {{{
## Primary output {{{
### If the primary output wasn't manually defined,
### try to get it's name
if [ -z "${MAIN_OUTPUT_NAME}" ]; then
if [ -z "${PRIMARY_OUTPUT_NAME}" ]; then
get_primary_output_name
fi
debug_message "define_vars \
The primary output is: ${MAIN_OUTPUT_NAME}."
The primary output is: ${PRIMARY_OUTPUT_NAME}."
## }}}
return_second_output_name="0"
@ -48,6 +52,7 @@ The primary output is: ${MAIN_OUTPUT_NAME}."
The second connected output is: ${SECOND_OUTPUT_NAME}."
return "${return_second_output_name}"
}
# }}}
get_primary_output_name() { # {{{
@ -83,7 +88,7 @@ Ensure to have a primary, LVDS or any connected output in xrandr."
fi
fi
readonly MAIN_OUTPUT_NAME="${local_primary_output_name}"
readonly PRIMARY_OUTPUT_NAME="${local_primary_output_name}"
}
# }}}
is_proc_running() { # {{{
@ -118,39 +123,41 @@ main() { # {{{
}
# }}}
## Define all vars
# Define all vars
define_vars
# Manage arguments # {{{
# This code can't be in a function due to arguments
case "${1}" in
off )
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'
;;
leftof | left-of | ds | dockstation | work )
#xrandr --output VGA-1 --mode 1024x768 --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --mode 1366x768
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
printf "%b\n" 'Xrandr for second output left-of main screen'
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 "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
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 "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
printf "%b\n" 'Xrandr for second output left-of main screen'
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
printf "%b\n" 'Xrandr for second output left-of primary screen'
;;
above )
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
printf "%b\n" 'Xrandr for dual screen with DisplayPort'
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
printf "%b\n" 'Xrandr for second output above primary screen'
;;
out | game )
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
out | game | second )
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --off
printf "%b\n" 'Xrandr for second output only'
;;
first_off | main_off | laptop_off )
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
primary_off | first_off | main_off | laptop_off )
xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --off
printf "%b\n" 'Xrandr to disable primary output'
;;
* )
printf "%b\n" 'Bad argument, please use [vga|hdmi|ds|work|off]'
printf "%b\n" 'Bad argument, please use [primary|left-of|right-of|above|second|primary_off|...]'
exit 1
;;
esac