From fd63440ff7192390e14919d9b5c4fbdb9905160e Mon Sep 17 00:00:00 2001 From: C4N-6 <82795828+C4N-6@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:43:49 -0500 Subject: [PATCH 1/2] Create volum.sh added a script to fade the volume --- volum.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 volum.sh diff --git a/volum.sh b/volum.sh new file mode 100644 index 0000000..88c4731 --- /dev/null +++ b/volum.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# a script to fade the volue to a given volume +# -e: volum where the fade ends at, Defaults to 50 +# -s: volum where the fade start at, Defaults to current volume +# -w: wait time, the time between each volume change + +START_VOL=$((($(cmus-remote -Q | grep -e "vol_left" | cut -d ' ' -f3) + $(cmus-remote -Q | grep -e "vol_right" | cut -d ' ' -f3)) / 2)) +END_VOL=50 + +SLEEP_TIME=0.01 + +function getOptions() { + local flag + while getopts "s:e:w:" flag; do + case "$flag" in + s) START_VOL=$OPTARG ;; + e) END_VOL=$OPTARG ;; + w) SLEEP_TIME=$OPTARG ;; + *) + echo "Unknown option: -$OPTARG" >&2 + exit + ;; + esac + done +} + +function main() { + local item + for item in $(seq "$START_VOL" "$END_VOL"); do + cmus-remote -v "$item" + sleep "$SLEEP_TIME" + done +} +getOptions "$@" + +main & From 5bbe7a73f46b0c94796ef8277b8a40169d2e1ae1 Mon Sep 17 00:00:00 2001 From: C4N-6 <82795828+C4N-6@users.noreply.github.com> Date: Sat, 15 Nov 2025 20:56:52 -0500 Subject: [PATCH 2/2] Update and rename volum.sh to volume.sh added comments a help flag fixed a spelling mistake --- volum.sh | 36 ------------------------------------ volume.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 36 deletions(-) delete mode 100644 volum.sh create mode 100644 volume.sh diff --git a/volum.sh b/volum.sh deleted file mode 100644 index 88c4731..0000000 --- a/volum.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# a script to fade the volue to a given volume -# -e: volum where the fade ends at, Defaults to 50 -# -s: volum where the fade start at, Defaults to current volume -# -w: wait time, the time between each volume change - -START_VOL=$((($(cmus-remote -Q | grep -e "vol_left" | cut -d ' ' -f3) + $(cmus-remote -Q | grep -e "vol_right" | cut -d ' ' -f3)) / 2)) -END_VOL=50 - -SLEEP_TIME=0.01 - -function getOptions() { - local flag - while getopts "s:e:w:" flag; do - case "$flag" in - s) START_VOL=$OPTARG ;; - e) END_VOL=$OPTARG ;; - w) SLEEP_TIME=$OPTARG ;; - *) - echo "Unknown option: -$OPTARG" >&2 - exit - ;; - esac - done -} - -function main() { - local item - for item in $(seq "$START_VOL" "$END_VOL"); do - cmus-remote -v "$item" - sleep "$SLEEP_TIME" - done -} -getOptions "$@" - -main & diff --git a/volume.sh b/volume.sh new file mode 100644 index 0000000..de54b6a --- /dev/null +++ b/volume.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# a script to fade the volume to a given volume +# -e: volume where the fade ends at, Defaults to 50 +# -s: volume where the fade start at, Defaults to current volume +# -w: wait time, the time between each volume change + +# gets the average of left and right volume +START_VOL=$((($(cmus-remote -Q | grep -e "vol_left" | cut -d ' ' -f3) + $(cmus-remote -Q | grep -e "vol_right" | cut -d ' ' -f3)) / 2)) +END_VOL=50 + +SLEEP_TIME=0.01 + +function getOptions() { + local flag + while getopts "s:e:w:h" flag; do + case "$flag" in + s) START_VOL=$OPTARG ;; + e) END_VOL=$OPTARG ;; + w) SLEEP_TIME=$OPTARG ;; + h) + echo "a script to fade the volume to a given volume" + echo "-e: volume where the fade ends at, Defaults to 50" + echo "-s: volume where the fade start at, Defaults to current volume" + echo "-w: wait time, the time between each volume change" + ;; + *) + echo "Unknown option: -$OPTARG" >&2 + exit + ;; + esac + done +} + +function main() { + local vol + for vol in $(seq "$START_VOL" "$END_VOL"); do + cmus-remote -v "$vol" # set volume + sleep "$SLEEP_TIME" # wait volume + done +} +getOptions "$@" + +main & # in parallel so we can use the terminal while the volume is changing