From e48979ba0a7a35c73f68048fb7ed1813cf047331 Mon Sep 17 00:00:00 2001 From: David Kramer Date: Wed, 13 Jun 2018 10:08:02 -0600 Subject: [PATCH] Add termux-volume --- scripts/termux-volume | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/termux-volume diff --git a/scripts/termux-volume b/scripts/termux-volume new file mode 100755 index 0000000..410c771 --- /dev/null +++ b/scripts/termux-volume @@ -0,0 +1,30 @@ +#!/data/data/com.termux/files/usr/bin/bash +set -e -u + +SCRIPTNAME=termux-volume +show_usage () { + echo "Usage: $SCRIPTNAME stream volume" + echo "Change volume of audio stream" + echo "Valid audio streams are: alarm, music, notification, ring, system, call" + echo "Call w/o arguments to show information about each audio stream" + exit 0 +} + +ARGS="" + +# If we have arguments, we must have 2 +# Otherwise we will just return JSON info to user +if [ $# -gt 0 ]; then + if [ $# -ne 2 ]; then + echo "Invalid argument count" + show_usage + fi + + if ! [[ $2 =~ ^[0-9]+$ ]]; then + echo "ERROR: Volume must be a number" + show_usage + fi + ARGS="-a set-volume --es stream $1 --ei volume $2" +fi + +/data/data/com.termux/files/usr/libexec/termux-api Volume $ARGS