Try to get primary output name
This commit is contained in:
parent
37629b6e70
commit
45613fb4a7
27
ecran
27
ecran
|
@ -13,7 +13,8 @@ readonly RESET='\033[0m'
|
||||||
readonly COLOR_DEBUG="${PURPLE}"
|
readonly COLOR_DEBUG="${PURPLE}"
|
||||||
|
|
||||||
## First and main screen (laptop screen,…)
|
## 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() { # {{{
|
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"
|
return_second_output_name="0"
|
||||||
|
|
||||||
SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${MAIN_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
|
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}"
|
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() { # {{{
|
is_proc_running() { # {{{
|
||||||
|
|
||||||
local_proc_pattern="${1}"
|
local_proc_pattern="${1}"
|
||||||
|
|
Loading…
Reference in New Issue