zpac: add support for easyeffects + sink ops
This commit is contained in:
parent
bb5f648282
commit
e7787bf558
1 changed files with 42 additions and 8 deletions
50
zpac/zpac
50
zpac/zpac
|
|
@ -7,6 +7,7 @@ usage()
|
||||||
echo "Usage: zpac <operation> [sub-operation]"
|
echo "Usage: zpac <operation> [sub-operation]"
|
||||||
echo "Operations:"
|
echo "Operations:"
|
||||||
echo " master : Master volume operation"
|
echo " master : Master volume operation"
|
||||||
|
echo " sink : Sink volume operation"
|
||||||
echo " app : Application volume operation"
|
echo " app : Application volume operation"
|
||||||
echo " mic : Mic operation"
|
echo " mic : Mic operation"
|
||||||
echo " fx : FX operation"
|
echo " fx : FX operation"
|
||||||
|
|
@ -35,24 +36,24 @@ tsched_1() {
|
||||||
|
|
||||||
FXon()
|
FXon()
|
||||||
{
|
{
|
||||||
screen -dmS "pulseeffects" pulseeffects --gapplication-service > /dev/null 2>&1
|
screen -dmS "$FXcmd" $FXcmd --gapplication-service > /dev/null 2>&1
|
||||||
echo "FX on"
|
echo "FX on"
|
||||||
}
|
}
|
||||||
FXoff()
|
FXoff()
|
||||||
{
|
{
|
||||||
pulseeffects -q
|
$FXcmd -q
|
||||||
echo "FX off"
|
echo "FX off"
|
||||||
}
|
}
|
||||||
FXtoggle()
|
FXtoggle()
|
||||||
{
|
{
|
||||||
if [ "$(pgrep -c pulseeffects)" -lt 1 ]
|
if [ "$(pgrep -c $FXcmd)" -lt 1 ]
|
||||||
then FXon
|
then FXon
|
||||||
else FXoff
|
else FXoff
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
FXstate()
|
FXstate()
|
||||||
{
|
{
|
||||||
if [ "$(pgrep -c pulseeffects)" -ge 1 ]
|
if [ "$(pgrep -c $FXcmd)" -ge 1 ]
|
||||||
then echo "FX on"
|
then echo "FX on"
|
||||||
else echo "FX off"
|
else echo "FX off"
|
||||||
fi
|
fi
|
||||||
|
|
@ -90,6 +91,14 @@ master_index() {
|
||||||
list_sinks | grep -E "(^Sink #)|(State: RUNNING)" | grep "State: RUNNING" -B1 | head -n1 | cut -d'#' -f2
|
list_sinks | grep -E "(^Sink #)|(State: RUNNING)" | grep "State: RUNNING" -B1 | head -n1 | cut -d'#' -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sink_list() {
|
||||||
|
list_sinks | grep "Description:" | cut -d: -f2- | cut -d' ' -f2-
|
||||||
|
}
|
||||||
|
|
||||||
|
sink_get_index() {
|
||||||
|
list_sinks | grep -E "(^Sink #)|(Description:)" | grep "Description: $1" -B1 | head -n1 | cut -d'#' -f2
|
||||||
|
}
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# SINK OPERATIONS
|
# SINK OPERATIONS
|
||||||
sinkvolume()
|
sinkvolume()
|
||||||
|
|
@ -114,7 +123,7 @@ sinkmutestate()
|
||||||
}
|
}
|
||||||
sinkmuteset()
|
sinkmuteset()
|
||||||
{
|
{
|
||||||
R="$(pactl set-sink-mute "$1" "$2")"
|
R="$(pactl set-sink-mute "$1" "$2" 2>&1)"
|
||||||
if [ -z "$R" ] ; then
|
if [ -z "$R" ] ; then
|
||||||
if [ "$2" -eq 1 ]
|
if [ "$2" -eq 1 ]
|
||||||
then echo "$3 mute on"
|
then echo "$3 mute on"
|
||||||
|
|
@ -238,6 +247,7 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$1" = "master" ]
|
elif [ "$1" = "master" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
get_list_sinks
|
get_list_sinks
|
||||||
case $2 in
|
case $2 in
|
||||||
setvolume) sinkvolumeset $(master_index) $3 "master" ;;
|
setvolume) sinkvolumeset $(master_index) $3 "master" ;;
|
||||||
|
|
@ -254,6 +264,28 @@ then
|
||||||
*) echo "zpac master <volume/setvolume/mute>" && exit 1 ;;
|
*) echo "zpac master <volume/setvolume/mute>" && exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
elif [ "$1" = "sink" ]
|
||||||
|
then
|
||||||
|
get_list_sinks
|
||||||
|
if [ "$2" = list ] ; then
|
||||||
|
sink_list
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
case $3 in
|
||||||
|
setvolume) sinkvolumeset "$(sink_get_index "$2")" "$4" "$2" ;;
|
||||||
|
volume) sinkvolumep "$(sink_get_index "$2")" "$4" "$2" ;;
|
||||||
|
mute)
|
||||||
|
case $4 in
|
||||||
|
on) sinkmuteset "$(sink_get_index "$2")" 1 "$2" ;;
|
||||||
|
off) sinkmuteset "$(sink_get_index "$2")" 0 "$2" ;;
|
||||||
|
toggle) sinkmutetoggle "$(sink_get_index "$2")" "$2" ;;
|
||||||
|
state) sinkmutestate "$(sink_get_index "$2")" "$2" ;;
|
||||||
|
*) echo "zpac sink <sink> mute <on/off/toggle/state>" && exit 1 ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*) echo "zpac sink <sink> <volume/setvolume/mute>" && exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
elif [ "$1" = "app" ]
|
elif [ "$1" = "app" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
|
@ -358,15 +390,17 @@ then
|
||||||
|
|
||||||
elif [ "$1" = "fx" ]
|
elif [ "$1" = "fx" ]
|
||||||
then
|
then
|
||||||
[ -z "$(which pulseeffects)" ] && echo "No FX available" >&2 && exit 1
|
FXcmd=easyeffects
|
||||||
|
which easyeffects >/dev/null 2>&1 || { which pulseeffects >/dev/null 2>&1 && FXcmd=pulseeffects ; } || {
|
||||||
|
echo "No FX available" >&2 && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
case $2 in
|
case $2 in
|
||||||
on|off|toggle|state) MODE=$2 ;;
|
on|off|toggle|state) MODE=$2 ;;
|
||||||
*) echo "zpac fx <on/off/toggle/state>" && exit 1 ;;
|
*) echo "zpac fx <on/off/toggle/state>" && exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$3" ] #all fx
|
if [ -z "$3" ] ; then
|
||||||
then
|
|
||||||
case $MODE in
|
case $MODE in
|
||||||
on) FXon ;;
|
on) FXon ;;
|
||||||
off) FXoff ;;
|
off) FXoff ;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue