Clean second_output_mode management
This commit is contained in:
parent
3d5323c9bc
commit
fa598cb48d
31
ecran
31
ecran
@ -20,6 +20,8 @@ readonly COLOR_DEBUG="${PURPLE}"
|
|||||||
## It can be forced here or the script will try to discover it's name
|
## It can be forced here or the script will try to discover it's name
|
||||||
#readonly SECOND_OUTPUT_NAME
|
#readonly SECOND_OUTPUT_NAME
|
||||||
|
|
||||||
|
readonly SECOND_OUTPUT_MODE="--auto"
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
debug_message() { # {{{
|
debug_message() { # {{{
|
||||||
@ -34,6 +36,10 @@ debug_message() { # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
define_vars() { # {{{
|
define_vars() { # {{{
|
||||||
|
|
||||||
|
[ -f "${HOME}/.config/xrandr.conf" ] && \
|
||||||
|
. "${HOME}/.config/xrandr.conf" && \
|
||||||
|
printf "%b\n" 'Use local config file.'
|
||||||
|
|
||||||
## Primary output {{{
|
## Primary output {{{
|
||||||
### If the primary output wasn't manually defined,
|
### If the primary output wasn't manually defined,
|
||||||
### try to get it's name
|
### try to get it's name
|
||||||
@ -53,9 +59,14 @@ The second output is: ${SECOND_OUTPUT_NAME}."
|
|||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
[ -f "${HOME}/.config/xrandr.conf" ] && \
|
## Second output mode {{{
|
||||||
. "${HOME}/.config/xrandr.conf" && \
|
### If second_output_mode wasn't defined (~/.config/xrandr.conf file, var env…)
|
||||||
printf "%b\n" 'Use local config file.'
|
### Use default value
|
||||||
|
### Then use ${second_output_mode} variable without "" to be able to use it as xrandr's option
|
||||||
|
if [ -z "${second_output_mode}" ]; then
|
||||||
|
second_output_mode=${SECOND_OUTPUT_MODE}
|
||||||
|
fi
|
||||||
|
## }}}
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
@ -146,30 +157,30 @@ case "${1}" in
|
|||||||
leftof | left-of | ds | dock | dockstation | work )
|
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 VGA-1 --mode 1024x768 --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode 1366x768
|
||||||
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
||||||
else
|
else
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --left-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
fi
|
fi
|
||||||
printf "%b\n" 'Xrandr for second output left-of primary screen'
|
printf "%b\n" 'Xrandr for second output left-of primary screen'
|
||||||
;;
|
;;
|
||||||
rightof | right-of | home )
|
rightof | right-of | home )
|
||||||
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
||||||
else
|
else
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --right-of "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
fi
|
fi
|
||||||
printf "%b\n" 'Xrandr for second output left-of primary screen'
|
printf "%b\n" 'Xrandr for second output left-of primary screen'
|
||||||
;;
|
;;
|
||||||
above )
|
above )
|
||||||
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
if [ -n "${PRIMARY_OUTPUT_MODE}" ]; then
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --mode "${PRIMARY_OUTPUT_MODE}"
|
||||||
else
|
else
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --above "${PRIMARY_OUTPUT_NAME:=/dev/null}" --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
fi
|
fi
|
||||||
printf "%b\n" 'Xrandr for second output above primary screen'
|
printf "%b\n" 'Xrandr for second output above primary screen'
|
||||||
;;
|
;;
|
||||||
out | game | second )
|
out | game | second )
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --off
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" ${second_output_mode} --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --off
|
||||||
printf "%b\n" 'Xrandr for second output only'
|
printf "%b\n" 'Xrandr for second output only'
|
||||||
;;
|
;;
|
||||||
primary_off | first_off | main_off | laptop_off )
|
primary_off | first_off | main_off | laptop_off )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user