|
|
|
@ -39,6 +39,31 @@ function display_config() {
|
|
|
|
display_configurations[$display_name]="$display_config"
|
|
|
|
display_configurations[$display_name]="$display_config"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function guess_output_from_class() {
|
|
|
|
|
|
|
|
display_class="$1"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canonical_display_name=''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for display in "${!display_configurations[@]}"; do
|
|
|
|
|
|
|
|
if [[ ( $display == ${display_class}* ) && \
|
|
|
|
|
|
|
|
( "${connected_displays[$display]}" == 'yes' ) ]]; then
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $canonical_display_name == '' ]]; then
|
|
|
|
|
|
|
|
canonical_display_name="$display"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "Multiple displays of class ${display_class} are connected. Quitting."
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $canonical_display_name == '' ]]; then
|
|
|
|
|
|
|
|
echo "No displays of class ${display_class} found. Quitting."
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$canonical_display_name"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declare -A display_configurations
|
|
|
|
declare -A display_configurations
|
|
|
|
declare -A connected_displays
|
|
|
|
declare -A connected_displays
|
|
|
|
|
|
|
|
|
|
|
|
@ -62,17 +87,18 @@ while read -r display_line; do
|
|
|
|
display_configurations[$display_name]=' --off'
|
|
|
|
display_configurations[$display_name]=' --off'
|
|
|
|
done <<< "$(xrandr | grep connected)"
|
|
|
|
done <<< "$(xrandr | grep connected)"
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: I'm very lazy, so build a method that automatically figures out which HDMI
|
|
|
|
# TODO: These cases can probably just be read from input now.
|
|
|
|
# output to use if there's only one.
|
|
|
|
|
|
|
|
case $display_profile in
|
|
|
|
case $display_profile in
|
|
|
|
'lvds-hdmi1')
|
|
|
|
'lvds-hdmi')
|
|
|
|
|
|
|
|
hdmi_display="$(guess_output_from_class "HDMI")"
|
|
|
|
display_config 'LVDS1' '--primary --mode 1366x768'
|
|
|
|
display_config 'LVDS1' '--primary --mode 1366x768'
|
|
|
|
display_config 'HDMI1' '--mode 1280x720 --above LVDS1'
|
|
|
|
display_config "$hdmi_display" '--mode 1280x720 --above LVDS1'
|
|
|
|
audio_profile='output:hdmi-stereo'
|
|
|
|
audio_profile='output:hdmi-stereo'
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
'hdmi1')
|
|
|
|
'hdmi')
|
|
|
|
display_config 'HDMI1' '--primary --mode 1280x720'
|
|
|
|
hdmi_display="$(guess_output_from_class "HDMI")"
|
|
|
|
|
|
|
|
display_config "$hdmi_display" '--primary --mode 1280x720'
|
|
|
|
audio_profile='output:hdmi-stereo'
|
|
|
|
audio_profile='output:hdmi-stereo'
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
@ -95,5 +121,6 @@ esac
|
|
|
|
|
|
|
|
|
|
|
|
call_xrandr
|
|
|
|
call_xrandr
|
|
|
|
if [ "$switch_audio" = 'yes' ]; then
|
|
|
|
if [ "$switch_audio" = 'yes' ]; then
|
|
|
|
|
|
|
|
# TODO: Figure out how to remove this dependency.
|
|
|
|
ponymix -c 0 set-profile "${audio_profile}"
|
|
|
|
ponymix -c 0 set-profile "${audio_profile}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|