audio --switch
This commit is contained in:
@@ -2,43 +2,74 @@
|
||||
|
||||
# available sinks listed here: pactl list sinks
|
||||
|
||||
CURRENT_SINK="$(pactl get-default-sink)"
|
||||
CURRENT_PRESET="$(easyeffects --active-preset output)"
|
||||
LOUD_SINK="alsa_output.pci-0000_00_1f.3.analog-stereo"
|
||||
LOUD_PRESET="Defender"
|
||||
HEAD_SINK="alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo"
|
||||
HEAD_PRESET="Techno"
|
||||
|
||||
set_head() {
|
||||
if [ "$CURRENT_SINK" != "$HEAD_SINK" ]; then
|
||||
pactl set-default-sink "$HEAD_SINK" || exit 1
|
||||
easyeffects --load-preset "$HEAD_PRESET" || exit 2
|
||||
echo -e "Current sink\t: $HEAD_SINK"
|
||||
echo -e "Current preset\t: $HEAD_PRESET"
|
||||
fi
|
||||
}
|
||||
|
||||
set_loud() {
|
||||
if [ "$CURRENT_SINK" != "$LOUD_SINK" ]; then
|
||||
pactl set-default-sink "$LOUD_SINK" || exit 1
|
||||
easyeffects --load-preset "$LOUD_PRESET" || exit 2
|
||||
echo -e "Current sink\t: $LOUD_SINK"
|
||||
echo -e "Current preset\t: $LOUD_PRESET"
|
||||
fi
|
||||
}
|
||||
|
||||
show_help() {
|
||||
echo "Usage: $(basename "$0") [-h|--help|--loud|--head|--switch]"
|
||||
echo
|
||||
echo "Switch audio output and apply appropriate easyffects preset."
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " --loud Enable loud speakers"
|
||||
echo " --head Enable headphones"
|
||||
echo " --switch Switch between loud and headphones"
|
||||
echo
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo -e "Current sink\t: $(pactl get-default-sink)"
|
||||
echo -e "Loud sink\t: $LOUD_SINK"
|
||||
echo -e "Loud preset\t: $LOUD_PRESET"
|
||||
echo -e "Head sink\t: $HEAD_SINK"
|
||||
echo -e "Head preset\t: $HEAD_PRESET"
|
||||
echo
|
||||
echo -e "Current sink\t: $CURRENT_SINK"
|
||||
echo -e "Current preset\t: $CURRENT_PRESET"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [-h]
|
||||
|
||||
Switch audio output and apply appropriate easyffects preset.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
--loud Enable loud speakers
|
||||
--head Enable headphones
|
||||
|
||||
EOF
|
||||
show_help
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" == "--loud" ]; then
|
||||
pactl set-default-sink "$LOUD_SINK" || exit 1
|
||||
easyeffects -l "$LOUD_PRESET" || exit 2
|
||||
set_loud
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" == "--head" ]; then
|
||||
pactl set-default-sink "$HEAD_SINK" || exit 1
|
||||
easyeffects -l "$HEAD_PRESET" || exit 2
|
||||
set_head
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" == "--switch" ]; then
|
||||
case "$CURRENT_SINK" in
|
||||
*$LOUD_SINK*) set_head ;;
|
||||
*$HEAD_SINK*) set_loud ;;
|
||||
*) show_help ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user