2014-09-25 23:37:13 +02:00
|
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
|
|
# Description: Manage video output (size, orientation, ...)
|
|
|
|
|
# And reload wm configuration
|
2020-08-21 19:58:25 +02:00
|
|
|
|
|
2020-08-21 20:02:03 +02:00
|
|
|
|
# Vars {{{
|
|
|
|
|
## First and main screen (laptop screen,…)
|
|
|
|
|
readonly MAIN_SCREEN="LVDS-1"
|
2014-09-25 23:37:13 +02:00
|
|
|
|
|
2020-08-21 20:02:03 +02:00
|
|
|
|
[ -z "${DEBUG}" ] && readonly DEBUG=0
|
|
|
|
|
|
|
|
|
|
## Colors
|
|
|
|
|
readonly PURPLE='\033[1;35m'
|
|
|
|
|
readonly RED='\033[0;31m'
|
|
|
|
|
readonly RESET='\033[0m'
|
|
|
|
|
readonly COLOR_DEBUG="${PURPLE}"
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
debug_message() { # {{{
|
|
|
|
|
|
|
|
|
|
local_message="${1}"
|
|
|
|
|
|
|
|
|
|
## Print message if DEBUG is enable (=0)
|
|
|
|
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG − ${PROGNAME}: ${local_message}"
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
# }}}
|
2020-08-21 21:09:00 +02:00
|
|
|
|
define_vars() { # {{{
|
2020-08-21 20:02:03 +02:00
|
|
|
|
|
2020-08-21 21:09:00 +02:00
|
|
|
|
return_second_output_name="0"
|
|
|
|
|
|
|
|
|
|
SECOND_OUTPUT=$(xrandr | grep " connected" | grep -v "${MAIN_SCREEN}" | awk 'NR==1{ print $1 }')
|
|
|
|
|
|
|
|
|
|
debug_message "define_vars − \
|
|
|
|
|
The second connected output is: ${SECOND_OUTPUT}."
|
|
|
|
|
|
|
|
|
|
return "${return_second_output_name}"
|
|
|
|
|
}
|
2020-08-21 20:02:03 +02:00
|
|
|
|
# }}}
|
2020-08-21 21:09:00 +02:00
|
|
|
|
main() { # {{{
|
2014-09-25 23:37:13 +02:00
|
|
|
|
|
2020-08-21 21:09:00 +02:00
|
|
|
|
## Define all vars
|
|
|
|
|
define_vars
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
main
|
|
|
|
|
|
|
|
|
|
# Manage arguments # {{{
|
|
|
|
|
# This code can't be in a function due to arguments
|
2014-09-25 23:37:13 +02:00
|
|
|
|
case "${1}" in
|
2017-09-28 22:10:20 +02:00
|
|
|
|
ds | dockstation | work )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
2017-09-28 22:10:20 +02:00
|
|
|
|
printf 'Xrandr for DisplayPort with dock station';;
|
2019-12-18 17:14:41 +01:00
|
|
|
|
home )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --right-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
2019-12-18 17:14:41 +01:00
|
|
|
|
printf 'Xrandr for home configuration';;
|
2019-11-23 12:17:50 +01:00
|
|
|
|
vga )
|
2020-08-21 19:58:25 +02:00
|
|
|
|
xrandr --output VGA-1 --mode 1024x768 --right-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
2017-09-28 22:10:20 +02:00
|
|
|
|
printf 'Xrandr for dual screen with VGA';;
|
|
|
|
|
hdmi | dp | displayport )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --above "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
2017-09-28 22:10:20 +02:00
|
|
|
|
printf 'Xrandr for dual screen with DisplayPort';;
|
|
|
|
|
pres | prez | presentation )
|
2020-08-21 19:58:25 +02:00
|
|
|
|
xrandr --output VGA-1 --mode 1024x768 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
|
2017-09-28 22:10:20 +02:00
|
|
|
|
printf 'Xrandr for presentation';;
|
|
|
|
|
- | off )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
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
|
2017-09-28 22:10:20 +02:00
|
|
|
|
xrandr --output VGA --off
|
|
|
|
|
printf 'Desactivate all video output';;
|
|
|
|
|
out )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1920x1080 --output "${MAIN_SCREEN:=/dev/null}" --off
|
2017-09-28 22:09:12 +02:00
|
|
|
|
;;
|
2019-12-18 17:14:41 +01:00
|
|
|
|
game )
|
2020-08-21 21:12:15 +02:00
|
|
|
|
xrandr --output "${SECOND_OUTPUT:=/dev/null}" --mode 1680x1050 --output "${MAIN_SCREEN:=/dev/null}" --off
|
2020-08-21 19:58:25 +02:00
|
|
|
|
;;
|
|
|
|
|
first_off | main_off | laptop_off )
|
|
|
|
|
xrandr --output "${MAIN_SCREEN:=/dev/null}" --off
|
2019-12-18 17:14:41 +01:00
|
|
|
|
;;
|
2017-09-28 22:10:20 +02:00
|
|
|
|
* )
|
|
|
|
|
printf 'Bad argument, please use [vga|hdmi|ds|work|-|off]'
|
2020-08-21 21:09:00 +02:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
2014-09-25 23:37:13 +02:00
|
|
|
|
esac
|
|
|
|
|
|
2020-08-21 21:09:00 +02:00
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
# Update herbstluftWM configuration
|
2014-09-25 23:37:13 +02:00
|
|
|
|
herbstclient detect_monitors
|
|
|
|
|
herbstclient reload
|
|
|
|
|
|
|
|
|
|
exit 0
|