95 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
| #! /bin/sh
 | ||
| 
 | ||
| # Description:      Manage video output (size, orientation, ...)
 | ||
| #                   And reload wm configuration
 | ||
| 
 | ||
| # Vars {{{
 | ||
| ## First and main screen (laptop screen,…)
 | ||
| readonly MAIN_SCREEN="LVDS-1"
 | ||
| 
 | ||
| [ -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
 | ||
| }
 | ||
| # }}}
 | ||
| define_vars() {                                                 # {{{
 | ||
| 
 | ||
| 	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}"
 | ||
| }
 | ||
| # }}}
 | ||
| main() {                                                        # {{{
 | ||
| 
 | ||
| 	## Define all vars
 | ||
| 	define_vars
 | ||
| 
 | ||
| }
 | ||
| # }}}
 | ||
| 
 | ||
| main
 | ||
| 
 | ||
| # Manage arguments                                                # {{{
 | ||
| # This code can't be in a function due to arguments
 | ||
| case "${1}" in
 | ||
| 	ds | dockstation | work )
 | ||
| 		xrandr --output DP-1 --mode 1920x1080 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768
 | ||
| 		printf 'Xrandr for DisplayPort with dock station';;
 | ||
| 	home )
 | ||
| 		xrandr --output DP-1 --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 HDMI-1 --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 HDMI-1 --off --output VGA-1 --off --output HDMI-3 --off --output DP-1 --off
 | ||
| 		xrandr --output VGA --off
 | ||
| 		printf 'Desactivate all video output';;
 | ||
| 	out )
 | ||
| 		xrandr --output HDMI-3 --mode 1920x1080 --output "${MAIN_SCREEN:=/dev/null}" --off
 | ||
| 		;;
 | ||
| 	game )
 | ||
| 		xrandr --output HDMI-1 --mode 1680x1050 --output "${MAIN_SCREEN:=/dev/null}" --off
 | ||
| 		;;
 | ||
| 	first_off | main_off | laptop_off )
 | ||
| 		xrandr --output "${MAIN_SCREEN:=/dev/null}" --off
 | ||
| 		;;
 | ||
| 	* )
 | ||
| 		printf 'Bad argument, please use [vga|hdmi|ds|work|-|off]'
 | ||
| 		exit 1
 | ||
| 		;;
 | ||
| esac
 | ||
| 
 | ||
| # }}}
 | ||
| 
 | ||
| # Update herbstluftWM configuration
 | ||
| herbstclient detect_monitors
 | ||
| herbstclient reload
 | ||
| 
 | ||
| exit 0
 |