sxmo_audio.sh drop alsa support
Now that we support Pipewire and Pulseaudio, and that we automatically determine available output ports, this is useless and badly supported.
This commit is contained in:
@@ -24,150 +24,150 @@ notifyvol() {
|
||||
}
|
||||
|
||||
# adjust *output* vol/mute
|
||||
pulsevolup() {
|
||||
volup() {
|
||||
pactl set-sink-volume @DEFAULT_SINK@ +"${1:-5}%"
|
||||
}
|
||||
|
||||
pulsevoldown() {
|
||||
voldown() {
|
||||
pactl set-sink-volume @DEFAULT_SINK@ -"${1:-5}%"
|
||||
}
|
||||
|
||||
pulsevoltogglemute() {
|
||||
voltogglemute() {
|
||||
pactl set-sink-mute @DEFAULT_SINK@ toggle
|
||||
}
|
||||
|
||||
pulsevolismuted() {
|
||||
volismuted() {
|
||||
pactl get-sink-mute @DEFAULT_SINK@ | grep -q "Mute: yes"
|
||||
}
|
||||
|
||||
pulsevolget() {
|
||||
if pulsevolismuted; then
|
||||
volget() {
|
||||
if volismuted; then
|
||||
printf "muted"
|
||||
else
|
||||
pactl get-sink-volume @DEFAULT_SINK@ | head -n1 | cut -d'/' -f2 | sed 's/ //g' | sed 's/\%//'
|
||||
fi
|
||||
}
|
||||
|
||||
pulsevolset() {
|
||||
volset() {
|
||||
pactl set-sink-volume @DEFAULT_SINK@ "$1"%
|
||||
}
|
||||
|
||||
# adjust *input* vol/mute
|
||||
pulsemicvolup() {
|
||||
micvolup() {
|
||||
pactl set-source-volume @DEFAULT_SOURCE@ +"${1:-5}%"
|
||||
}
|
||||
|
||||
pulsemicvoldown() {
|
||||
micvoldown() {
|
||||
pactl set-source-volume @DEFAULT_SOURCE@ -"${1:-5}%"
|
||||
}
|
||||
|
||||
pulsemictogglemute() {
|
||||
mictogglemute() {
|
||||
pactl set-source-mute @DEFAULT_SOURCE@ toggle
|
||||
}
|
||||
|
||||
pulsemicismuted() {
|
||||
micismuted() {
|
||||
pactl get-source-mute @DEFAULT_SOURCE@ | grep -q "Mute: yes"
|
||||
}
|
||||
|
||||
pulsemicvolget() {
|
||||
if pulsemicismuted; then
|
||||
micvolget() {
|
||||
if micismuted; then
|
||||
printf "muted"
|
||||
else
|
||||
pactl get-source-volume @DEFAULT_SOURCE@ | head -n1 | cut -d'/' -f2 | sed 's/ //g' | sed 's/\%//'
|
||||
fi
|
||||
}
|
||||
|
||||
pulsemicvolset() {
|
||||
micvolset() {
|
||||
pactl set-source-volume @DEFAULT_SOURCE@ "$1"%
|
||||
}
|
||||
|
||||
# set the *active port* for output
|
||||
pulsedeviceset() {
|
||||
deviceset() {
|
||||
pactl set-sink-port @DEFAULT_SINK@ "[Out] $1"
|
||||
}
|
||||
|
||||
# set the *active port* for input
|
||||
pulsedevicesetinput() {
|
||||
devicesetinput() {
|
||||
pactl set-source-port @DEFAULT_SOURCE@ "[In] $1"
|
||||
}
|
||||
|
||||
# get the *active port* for input
|
||||
pulsedevicegetinput() {
|
||||
devicegetinput() {
|
||||
[ -z "$1" ] && default_source="$(pactl get-default-source)" || default_source="$1"
|
||||
pactl --format=json list sources | jq -r ".[] | select(.name == \"$default_source\") | .active_port" | sed 's/\[In] //'
|
||||
}
|
||||
|
||||
# get the *active port* for output
|
||||
pulsedeviceget() {
|
||||
deviceget() {
|
||||
[ -z "$1" ] && default_sink="$(pactl get-default-sink)" || default_sink="$1"
|
||||
pactl --format=json list sinks | jq -r ".[] | select(.name == \"$default_sink\") | .active_port" | sed 's/\[Out] //'
|
||||
}
|
||||
|
||||
# get the default sink
|
||||
pulsedevicegetdefaultsink() {
|
||||
devicegetdefaultsink() {
|
||||
pactl get-default-sink
|
||||
}
|
||||
|
||||
# get the default source
|
||||
pulsedevicegetdefaultsource() {
|
||||
devicegetdefaultsource() {
|
||||
pactl get-default-source
|
||||
}
|
||||
|
||||
pulsesourceset() {
|
||||
sourceset() {
|
||||
pactl set-default-source "$1"
|
||||
}
|
||||
|
||||
pulsesinkset() {
|
||||
sinkset() {
|
||||
pactl set-default-sink "$1"
|
||||
}
|
||||
|
||||
# get a list of sinks
|
||||
_pulsesinkssubmenu() {
|
||||
_sinkssubmenu() {
|
||||
[ -z "$1" ] && default_sink="$(pactl get-default-sink)" || default_sink="$1"
|
||||
pactl --format=json list sinks | jq -r '.[] | .name, .description' | while read -r line; do
|
||||
name="$line"
|
||||
read -r description
|
||||
if [ "$default_sink" = "$name" ]; then
|
||||
printf "%s %s %s ^ pulsesinkset %s\n" "$icon_chk" "$icon_spk" "$description" "$name"
|
||||
printf "%s %s %s ^ sinkset %s\n" "$icon_chk" "$icon_spk" "$description" "$name"
|
||||
else
|
||||
printf " %s %s ^ pulsesinkset %s\n" "$icon_spk" "$description" "$name"
|
||||
printf " %s %s ^ sinkset %s\n" "$icon_spk" "$description" "$name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# get a list of output ports
|
||||
_pulseoutportssubmenu() {
|
||||
_outportssubmenu() {
|
||||
[ -z "$1" ] && default_sink="$(pactl get-default-sink)" || default_sink="$1"
|
||||
active_out_port="$(pulsedeviceget "$default_sink")"
|
||||
active_out_port="$(deviceget "$default_sink")"
|
||||
pactl --format=json list sinks | jq -r ".[] | select(.name == \"$default_sink\" ) | .ports[] | select(.availability != \"not available\" ) | .name" | sed 's/\[Out] //' | while read -r line; do
|
||||
[ "$active_out_port" = "$line" ] && icon="$icon_ton" || icon="$icon_tof"
|
||||
printf " %s %s ^ pulsedeviceset %s\n" "$icon" "$line" "$line"
|
||||
printf " %s %s ^ deviceset %s\n" "$icon" "$line" "$line"
|
||||
done
|
||||
}
|
||||
|
||||
# get a list of input sources
|
||||
_pulsesourcessubmenu() {
|
||||
_sourcessubmenu() {
|
||||
[ -z "$1" ] && default_source="$(pactl get-default-source)" || default_source="$1"
|
||||
pactl --format=json list sources | jq -r '.[] | select (.monitor_source == "") | .name, .description' | while read -r line; do
|
||||
name="$line"
|
||||
read -r description
|
||||
if [ "$default_source" = "$name" ]; then
|
||||
printf "%s %s %s ^ pulsesourceset %s\n" "$icon_chk" "$icon_mic" "$description" "$name"
|
||||
printf "%s %s %s ^ sourceset %s\n" "$icon_chk" "$icon_mic" "$description" "$name"
|
||||
else
|
||||
printf " %s %s ^ pulsesourceset %s\n" "$icon_mic" "$description" "$name"
|
||||
printf " %s %s ^ sourceset %s\n" "$icon_mic" "$description" "$name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# get a list of input ports
|
||||
_pulseinportssubmenu() {
|
||||
_inportssubmenu() {
|
||||
# if the Headset is NOT plugged in, then do not display Headset
|
||||
# as a option, as clicking on it causes pulse to unset the source!!
|
||||
[ -z "$1" ] && default_source="$(pactl get-default-source)" || default_source="$1"
|
||||
active_in_port="$(pulsedevicegetinput "$default_source")"
|
||||
active_in_port="$(devicegetinput "$default_source")"
|
||||
pactl --format=json list sources | jq -r ".[] | select(.name == \"$default_source\" ) | .ports[] | select(.availability != \"not available\" ) | .name" | sed 's/\[In] //' | while read -r line; do
|
||||
[ "$active_in_port" = "$line" ] && icon="$icon_ton" || icon="$icon_tof"
|
||||
printf " %s %s ^ pulsedevicesetinput %s\n" "$icon" "$line" "$line"
|
||||
printf " %s %s ^ devicesetinput %s\n" "$icon" "$line" "$line"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -197,136 +197,53 @@ _ringmodesubmenu() {
|
||||
fi
|
||||
}
|
||||
|
||||
pulsemenuchoices() {
|
||||
cur_vol="$(pulsevolget)"
|
||||
cur_mic_vol="$(pulsemicvolget)"
|
||||
default_sink_name="$(pulsedevicegetdefaultsink)"
|
||||
default_source_name="$(pulsedevicegetdefaultsource)"
|
||||
menuchoices() {
|
||||
cur_vol="$(volget)"
|
||||
cur_mic_vol="$(micvolget)"
|
||||
default_sink_name="$(devicegetdefaultsink)"
|
||||
default_source_name="$(devicegetdefaultsource)"
|
||||
grep . <<EOF
|
||||
$icon_cls Close Menu ^ exit
|
||||
Output:
|
||||
$(_pulsesinkssubmenu "$default_sink_name")
|
||||
$(_sinkssubmenu "$default_sink_name")
|
||||
$(
|
||||
if [ "$cur_vol" != "muted" ]; then
|
||||
printf " %s Volume (%s%%) ^ pulsevolup\n" "$icon_aru" "$cur_vol"
|
||||
printf " %s Volume (%s%%) ^ pulsevoldown\n" "$icon_ard" "$cur_vol"
|
||||
printf " %s Output Mute ^ pulsevoltogglemute\n" "$icon_tof"
|
||||
printf " %s Volume (%s%%) ^ volup\n" "$icon_aru" "$cur_vol"
|
||||
printf " %s Volume (%s%%) ^ voldown\n" "$icon_ard" "$cur_vol"
|
||||
printf " %s Output Mute ^ voltogglemute\n" "$icon_tof"
|
||||
else
|
||||
printf " %s Output Mute ^ pulsevoltogglemute\n" "$icon_ton"
|
||||
printf " %s Output Mute ^ voltogglemute\n" "$icon_ton"
|
||||
fi
|
||||
)
|
||||
$(_pulseoutportssubmenu "$default_sink_name")
|
||||
$(_outportssubmenu "$default_sink_name")
|
||||
Input:
|
||||
$(_pulsesourcessubmenu "$default_source_name")
|
||||
$(_sourcessubmenu "$default_source_name")
|
||||
$(
|
||||
if [ "$cur_mic_vol" != "muted" ]; then
|
||||
printf " %s Volume (%s%%) ^ pulsemicvolup\n" "$icon_aru" "$cur_mic_vol"
|
||||
printf " %s Volume (%s%%) ^ pulsemicvoldown\n" "$icon_ard" "$cur_mic_vol"
|
||||
printf " %s Input Mute ^ pulsemictogglemute\n" "$icon_tof"
|
||||
printf " %s Volume (%s%%) ^ micvolup\n" "$icon_aru" "$cur_mic_vol"
|
||||
printf " %s Volume (%s%%) ^ micvoldown\n" "$icon_ard" "$cur_mic_vol"
|
||||
printf " %s Input Mute ^ mictogglemute\n" "$icon_tof"
|
||||
else
|
||||
printf " %s Input Mute ^ pulsemictogglemute\n" "$icon_ton"
|
||||
printf " %s Input Mute ^ mictogglemute\n" "$icon_ton"
|
||||
fi
|
||||
)
|
||||
$(_pulseinportssubmenu "$default_source_name")
|
||||
$(_inportssubmenu "$default_source_name")
|
||||
Call Options:
|
||||
$(_callaudiodsubmenu)
|
||||
$(_ringmodesubmenu)
|
||||
EOF
|
||||
}
|
||||
|
||||
alsacurrentdevice() {
|
||||
if ! [ -f "$XDG_RUNTIME_DIR"/sxmo.audiocurrentdevice ]; then
|
||||
alsadeviceset "$SPEAKER"
|
||||
printf %s "$SPEAKER" > "$XDG_RUNTIME_DIR"/sxmo.audiocurrentdevice
|
||||
fi
|
||||
|
||||
cat "$XDG_RUNTIME_DIR"/sxmo.audiocurrentdevice
|
||||
}
|
||||
|
||||
amixerextractvol() {
|
||||
grep -oE '([0-9]+)%' |
|
||||
tr -d ' %' |
|
||||
awk '{ s += $1; c++ } END { print s/c }' |
|
||||
xargs printf %.0f
|
||||
}
|
||||
|
||||
alsavolup() {
|
||||
amixer -c "${SXMO_ALSA_CONTROL_NAME:-0}" set "$(alsacurrentdevice)" "${1:-5}%+" | amixerextractvol | notifyvol -
|
||||
}
|
||||
|
||||
alsavoldown() {
|
||||
amixer -c "${SXMO_ALSA_CONTROL_NAME:-0}" set "$(alsacurrentdevice)" "${1:-5}%-" | amixerextractvol | notifyvol -
|
||||
}
|
||||
|
||||
alsavolget() {
|
||||
if [ -n "$(alsacurrentdevice)" ]; then
|
||||
amixer -c "${SXMO_ALSA_CONTROL_NAME:-0}" get "$(alsacurrentdevice)" | amixerextractvol
|
||||
fi
|
||||
}
|
||||
|
||||
alsamicismuted() {
|
||||
echo "alsamicismuted: Not implemented">&2
|
||||
}
|
||||
|
||||
alsadeviceget() {
|
||||
case "$(alsacurrentdevice)" in
|
||||
"$SPEAKER")
|
||||
printf "Speaker"
|
||||
;;
|
||||
"$HEADPHONE")
|
||||
printf "Headphone"
|
||||
;;
|
||||
"$EARPIECE")
|
||||
printf "Earpiece"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
alsamenuchoices() {
|
||||
CURRENTDEV="$(alsacurrentdevice)"
|
||||
cat <<EOF
|
||||
$icon_cls Close Menu ^ exit
|
||||
$icon_hdp Headphones $([ "$CURRENTDEV" = "Headphone" ] && echo "$icon_chk") ^ alsadeviceset Headphones
|
||||
$icon_spk Speaker $([ "$CURRENTDEV" = "Line Out" ] && echo "$icon_chk") ^ alsadeviceset Speaker
|
||||
$icon_phn Earpiece $([ "$CURRENTDEV" = "Earpiece" ] && echo "$icon_chk") ^ alsadeviceset Earpiece
|
||||
$icon_mut None $([ -z "$CURRENTDEV" ] && echo "$icon_chk") ^ alsadeviceset
|
||||
$icon_aru Volume up ^ alsavolup
|
||||
$icon_ard Volume down ^ alsavoldown
|
||||
$(_ringmodesubmenu)
|
||||
EOF
|
||||
}
|
||||
|
||||
ispulse() {
|
||||
command -v pactl > /dev/null 2>&1 || return 1
|
||||
pactl info > /dev/null 2>&1 || return 1
|
||||
}
|
||||
|
||||
if [ -z "$*" ]; then
|
||||
set -- menu
|
||||
fi
|
||||
|
||||
backend="$AUDIO_BACKEND"
|
||||
if [ -z "$backend" ]; then
|
||||
if ispulse; then
|
||||
backend=pulse
|
||||
else
|
||||
backend=alsa
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$backend" = "alsa" ]; then
|
||||
# set some alsa specific things
|
||||
SPEAKER="${SXMO_SPEAKER:-"Line Out"}"
|
||||
HEADPHONE="${SXMO_HEADPHONE:-"Headphone"}"
|
||||
EARPIECE="${SXMO_EARPIECE:-"Earpiece"}"
|
||||
fi
|
||||
|
||||
cmd="$1"
|
||||
shift
|
||||
case "$cmd" in
|
||||
menu)
|
||||
while : ; do
|
||||
CHOICES="$("$backend"menuchoices)"
|
||||
CHOICES="$(menuchoices)"
|
||||
PICKED="$(
|
||||
printf "%s\n" "$CHOICES" |
|
||||
cut -d'^' -f1 |
|
||||
@@ -341,22 +258,22 @@ case "$cmd" in
|
||||
vol)
|
||||
verb="$1"
|
||||
shift
|
||||
"$backend"vol"$verb" "$@"
|
||||
vol"$verb" "$@"
|
||||
;;
|
||||
mic)
|
||||
verb="$1"
|
||||
shift
|
||||
"$backend"mic"$verb" "$@"
|
||||
mic"$verb" "$@"
|
||||
;;
|
||||
device)
|
||||
verb="$1"
|
||||
shift
|
||||
"$backend"device"$verb" "$1"
|
||||
device"$verb" "$1"
|
||||
;;
|
||||
notify)
|
||||
notifyvol "$("${backend}volget")"
|
||||
notifyvol "$(volget)"
|
||||
;;
|
||||
micnotify)
|
||||
notifyvol "$("${backend}micvolget")"
|
||||
notifyvol "$(micvolget)"
|
||||
;;
|
||||
esac
|
||||
|
@@ -62,15 +62,6 @@ SXMO_LED_GREEN_TYPE | LED device type, i.e., the part after the colon in the pa
|
||||
|
||||
SXMO_SWAY_SCALE | Screen scale for hidpi screens. Can be fractional [SWAY-ONLY].
|
||||
|
||||
### Music-related
|
||||
SXMO_SPEAKER | Audio device name for the main speaker [default: Speaker]
|
||||
|
||||
SXMO_EARPIECE | Audio device name for the earpiece speaker [default: Earpiece]
|
||||
|
||||
SXMO_HEADPHONE | Audio device name for the headphones [default: Headphone]
|
||||
|
||||
SXMO_ALSA_CONTROL_NAME | Alsa audio control name [default: 0]
|
||||
|
||||
### Input-related
|
||||
SXMO_TOUCHSCREEN_ID | ID (from xinput) for the touchscreen device [DWM-ONLY] [default: 10]
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
export SXMO_SYS_FILES="/sys/power/state /sys/devices/platform/soc/1f00000.rtc/power/wakeup /sys/power/mem_sleep /dev/rtc0 /sys/devices/platform/soc/1f03400.rsb/sunxi-rsb-3a3/axp221-pek/power/wakeup"
|
||||
export SXMO_TOUCHSCREEN_ID=8
|
||||
export SXMO_MONITOR="DSI-1"
|
||||
export SXMO_ALSA_CONTROL_NAME=PinePhone
|
||||
export SXMO_SWAY_SCALE="2"
|
||||
export SXMO_POWER_BUTTON="0:0:axp20x-pek"
|
||||
export SXMO_VOLUME_BUTTON="1:1:1c21800.lradc"
|
||||
|
Reference in New Issue
Block a user