Updated terminology and removed needless conditionals.

in-use
Emily Frost 7 years ago
parent 511a9db034
commit 06f7ad2dc1
No known key found for this signature in database
GPG Key ID: FD1FA524668FB1FA

@ -1,5 +1,15 @@
#!/bin/bash
# setdisplay
# A simple script to configure X and PulseAudio with predefined profiles.
### Usage
# setdisplay [PROFILE]
# Configure X with the specified profile, but don't change the audio profile.
# setdisplay -a [PROFILE]
# Configure X with the specified profile and change the audio profile to match it.
function call_xrandr() {
xrandr_opts=''
@ -34,9 +44,9 @@ declare -A connected_displays
if [ "$1" = '-a' ]; then
switch_audio='yes'
video_mode="$2"
display_profile="$2"
else
video_mode="$1"
display_profile="$1"
fi
@ -54,36 +64,31 @@ done <<< "$(xrandr | grep connected)"
# TODO: I'm very lazy, so build a method that automatically figures out which HDMI
# output to use if there's only one.
case $video_mode in
case $display_profile in
'lvds-hdmi1')
display_config 'LVDS1' '--primary --mode 1366x768'
display_config 'HDMI1' '--mode 1280x720 --above LVDS1'
if [ "$switch_audio" = 'yes' ]; then
audio_profile='output:hdmi-stereo'
fi
audio_profile='output:hdmi-stereo'
;;
'hdmi1')
display_config 'HDMI1' '--primary --mode 1280x720'
if [ "$switch_audio" = 'yes' ]; then
audio_profile='output:hdmi-stereo'
fi
audio_profile='output:hdmi-stereo'
;;
'lvds')
display_config 'LVDS1' '--primary --mode 1366x768'
if [ "$switch_audio" = 'yes' ]; then
audio_profile='output:analog-stereo'
fi
audio_profile='output:analog-stereo'
;;
# This is intended to be a quick rescue mode.
'')
display_config 'LVDS1' '--primary --mode 1377x768'
display_config 'LVDS1' '--primary --mode 1366x768'
audio_profile='output:analog-stereo'
;;
*)
echo "No configuration defined for ${video_mode}"
echo "No profile ${display_profile} has been defined."
exit 1
;;
esac

Loading…
Cancel
Save