Try to get primary output name

This commit is contained in:
gardouille 2020-10-23 09:03:36 +02:00
parent 37629b6e70
commit 45613fb4a7
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

27
ecran
View File

@ -13,7 +13,8 @@ readonly RESET='\033[0m'
readonly COLOR_DEBUG="${PURPLE}"
## First and main screen (laptop screen,…)
readonly MAIN_OUTPUT_NAME="LVDS-1"
## It can be forced here or the script will try to discover it's name
#readonly MAIN_OUTPUT_NAME="LVDS-1"
# }}}
@ -29,6 +30,16 @@ debug_message() { # {{{
# }}}
define_vars() { # {{{
## Primary output {{{
### If the primary output wasn't manually defined,
### try to get it's name
if [ -z "${MAIN_OUTPUT_NAME}" ]; then
get_primary_output_name
fi
debug_message "define_vars \
The primary output is: ${MAIN_OUTPUT_NAME}."
## }}}
return_second_output_name="0"
SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${MAIN_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
@ -39,6 +50,20 @@ The second connected output is: ${SECOND_OUTPUT_NAME}."
return "${return_second_output_name}"
}
# }}}
get_primary_output_name() { # {{{
## First, check if an output is already defined as primary
local_primary_output_name=$(xrandr | grep " primary" | awk 'NR==1{ print $1 }')
## If the var contains something
if [ -n "${local_primary_output_name}" ]; then
debug_message "get_primary_output_name \
An output is defined as primary: ${local_primary_output_name}".
fi
readonly MAIN_OUTPUT_NAME="${local_primary_output_name}"
}
# }}}
is_proc_running() { # {{{
local_proc_pattern="${1}"