Use --auto instead of --mode and clean duplicate
This commit is contained in:
parent
ccd620d6f4
commit
3ec797f4c8
51
ecran
51
ecran
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# Vars {{{
|
# Vars {{{
|
||||||
## First and main screen (laptop screen,…)
|
## First and main screen (laptop screen,…)
|
||||||
readonly MAIN_SCREEN="LVDS-1"
|
readonly MAIN_OUTPUT_NAME="LVDS-1"
|
||||||
|
|
||||||
[ -z "${DEBUG}" ] && readonly DEBUG=0
|
[ -z "${DEBUG}" ] && readonly DEBUG=0
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ define_vars() { # {{{
|
||||||
|
|
||||||
return_second_output_name="0"
|
return_second_output_name="0"
|
||||||
|
|
||||||
SECOND_OUTPUT=$(xrandr | grep " connected" | grep -v "${MAIN_SCREEN}" | awk 'NR==1{ print $1 }')
|
SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${MAIN_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
|
||||||
|
|
||||||
debug_message "define_vars − \
|
debug_message "define_vars − \
|
||||||
The second connected output is: ${SECOND_OUTPUT}."
|
The second connected output is: ${SECOND_OUTPUT_NAME}."
|
||||||
|
|
||||||
return "${return_second_output_name}"
|
return "${return_second_output_name}"
|
||||||
}
|
}
|
||||||
|
@ -51,36 +51,33 @@ main
|
||||||
# Manage arguments # {{{
|
# Manage arguments # {{{
|
||||||
# This code can't be in a function due to arguments
|
# This code can't be in a function due to arguments
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
ds | dockstation | work )
|
off )
|
||||||
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
## TODO : One command to enable main screen and a loop to disable all other connected output
|
||||||
printf 'Xrandr for DisplayPort with dock station';;
|
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
|
||||||
home )
|
|
||||||
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --right-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
|
||||||
printf 'Xrandr for home configuration';;
|
|
||||||
vga )
|
|
||||||
xrandr --output VGA-1 --mode 1024x768 --right-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
|
||||||
printf 'Xrandr for dual screen with VGA';;
|
|
||||||
hdmi | dp | displayport )
|
|
||||||
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --above "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
|
||||||
printf 'Xrandr for dual screen with DisplayPort';;
|
|
||||||
pres | prez | presentation )
|
|
||||||
xrandr --output VGA-1 --mode 1024x768 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
|
||||||
printf 'Xrandr for presentation';;
|
|
||||||
- | off )
|
|
||||||
xrandr --output "${MAIN_SCREEN:=/dev/null}" --mode 1360x768 --output "${SECOND_OUTPUT:=/dev/null}" --off --output VGA-1 --off --output HDMI-3 --off --output "${SECOND_OUTPUT:=/dev/null}" --off
|
|
||||||
xrandr --output VGA --off
|
xrandr --output VGA --off
|
||||||
printf 'Desactivate all video output';;
|
printf 'Desactivate all video output'
|
||||||
out )
|
|
||||||
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --output "${MAIN_SCREEN:=/dev/null}" --off
|
|
||||||
;;
|
;;
|
||||||
game )
|
leftof | left-of | ds | dockstation | work )
|
||||||
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1680x1050 --output "${MAIN_SCREEN:=/dev/null}" --off
|
#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 'Xrandr for second output left-of main 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 'Xrandr for second output left-of main screen'
|
||||||
|
;;
|
||||||
|
above )
|
||||||
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
|
printf 'Xrandr for dual screen with DisplayPort'
|
||||||
|
;;
|
||||||
|
out | game )
|
||||||
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
||||||
;;
|
;;
|
||||||
first_off | main_off | laptop_off )
|
first_off | main_off | laptop_off )
|
||||||
xrandr --output "${MAIN_SCREEN:=/dev/null}" --off
|
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
printf 'Bad argument, please use [vga|hdmi|ds|work|-|off]'
|
printf 'Bad argument, please use [vga|hdmi|ds|work|off]'
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue