Try to guess second output name if not already set
This commit is contained in:
		
							parent
							
								
									1d51457092
								
							
						
					
					
						commit
						5e23ba15d1
					
				
							
								
								
									
										24
									
								
								ecran
								
								
								
								
							
							
						
						
									
										24
									
								
								ecran
								
								
								
								
							| 
						 | 
					@ -43,15 +43,15 @@ define_vars() {                                                 # {{{
 | 
				
			||||||
	debug_message "define_vars − \
 | 
						debug_message "define_vars − \
 | 
				
			||||||
The primary output is: ${PRIMARY_OUTPUT_NAME}."
 | 
					The primary output is: ${PRIMARY_OUTPUT_NAME}."
 | 
				
			||||||
	## }}}
 | 
						## }}}
 | 
				
			||||||
 | 
						## Second output {{{
 | 
				
			||||||
	return_second_output_name="0"
 | 
						### If the second output wasn't manually defined,
 | 
				
			||||||
 | 
						### try to get it's name
 | 
				
			||||||
	SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${MAIN_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
 | 
						if [ -z "${SECOND_OUTPUT_NAME}" ]; then
 | 
				
			||||||
 | 
							SECOND_OUTPUT_NAME=$(xrandr | grep " connected" | grep -v "${PRIMARY_OUTPUT_NAME}" | awk 'NR==1{ print $1 }')
 | 
				
			||||||
		debug_message "define_vars − \
 | 
							debug_message "define_vars − \
 | 
				
			||||||
The second connected output is: ${SECOND_OUTPUT_NAME}."
 | 
					The second output is: ${SECOND_OUTPUT_NAME}."
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
	return "${return_second_output_name}"
 | 
						## }}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# }}}
 | 
					# }}}
 | 
				
			||||||
| 
						 | 
					@ -130,10 +130,10 @@ define_vars
 | 
				
			||||||
# 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
 | 
				
			||||||
	primary | off )
 | 
						primary | off )
 | 
				
			||||||
		## TODO : One command to enable main screen and a loop to disable all other connected output
 | 
							## TODO : One command to enable primary screen and a loop to disable all other connected output
 | 
				
			||||||
		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
 | 
							xrandr --output "${PRIMARY_OUTPUT_NAME:=/dev/null}" --auto
 | 
				
			||||||
		xrandr --output VGA --off
 | 
							if [ -n "${SECOND_OUTPUT_NAME}" ]; then xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off ; fi
 | 
				
			||||||
		printf "%b\n" 'Desactivate all video output'
 | 
							printf "%b\n" 'Enable only primary output'
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
	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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue