Minor corrections
This commit is contained in:
parent
e10bba90c2
commit
cfcb423770
43
volumectl
43
volumectl
@ -12,17 +12,18 @@ GET_VOLUME_FLAG="--get-volume"
|
|||||||
GET_MUTE_FLAG="--get-mute"
|
GET_MUTE_FLAG="--get-mute"
|
||||||
ADDITIONAL_FLAGS=("--allow-boost")
|
ADDITIONAL_FLAGS=("--allow-boost")
|
||||||
|
|
||||||
NOTIFICATION_ID=16674
|
|
||||||
|
|
||||||
## Default values
|
## Default values
|
||||||
NOTIFICATION=1
|
NOTIFICATION_ENABLED=1
|
||||||
|
NOTIFICATION_TIMEOUT=5
|
||||||
CONFIG_PATH="$XDG_CONFIG_HOME/`basename $0`/config.ini"
|
CONFIG_PATH="$XDG_CONFIG_HOME/`basename $0`/config.ini"
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
|
|
||||||
NORMAL_DELTA=5
|
NORMAL_DELTA=5
|
||||||
BIG_DELTA=10
|
BIG_DELTA=10
|
||||||
VOLUME_MAX=5
|
VOLUME_MAX=100
|
||||||
VOLUME_MIN=100
|
VOLUME_MIN=5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Args
|
## Args
|
||||||
OPTIONAL_FLAGS=("-v" "--verbose" "-c" "--config" "-n" "--notifcation" "-N" "--no-notification")
|
OPTIONAL_FLAGS=("-v" "--verbose" "-c" "--config" "-n" "--notifcation" "-N" "--no-notification")
|
||||||
@ -45,8 +46,9 @@ notify () {
|
|||||||
icon="audio-volume-high"
|
icon="audio-volume-high"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ $NOTIFICATION -eq 1 ]] && dunstify -h int:value:$volume -h string:x-dunst-stack-tag:volume -i "$icon" "Volume ($volume%)"
|
local cmd="dunstify -h int:value:$volume -h string:x-dunst-stack-tag:volume -i \"$icon\" \"Volume ($volume%)\""
|
||||||
|
[[ $NOTIFICATION_ENABLED -eq 1 ]] && sh -c "$cmd"
|
||||||
|
verbose && ( [[ $NOTIFICATION_ENABLED -eq 1 ]] && echo "Notified with \`$cmd\`" || echo "Didn't notify" )
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_up_by () {
|
volume_up_by () {
|
||||||
@ -144,7 +146,8 @@ get_mute () {
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
volumectl - A configurable bash script that makes your life easier in controlling you volume and notifying it.
|
volumectl - A configurable bash script that makes your life easier in controlling volume and notifying it
|
||||||
|
at the same time.
|
||||||
|
|
||||||
Usage: volumectl [-v|--verbose] [-c|--config path] [-n|-N] -option [arg]
|
Usage: volumectl [-v|--verbose] [-c|--config path] [-n|-N] -option [arg]
|
||||||
|
|
||||||
@ -154,6 +157,8 @@ Options:
|
|||||||
-I, --big-increase increase the volume by the "big" amount
|
-I, --big-increase increase the volume by the "big" amount
|
||||||
-D, --big-decrease decrease the volume by the "big" amount
|
-D, --big-decrease decrease the volume by the "big" amount
|
||||||
-s arg, --set arg set volume to arg
|
-s arg, --set arg set volume to arg
|
||||||
|
--set-min-volume set volume to maximum
|
||||||
|
--set-max-volume set volume to maximum
|
||||||
-m, --mute mute
|
-m, --mute mute
|
||||||
-u, --unmute unmute
|
-u, --unmute unmute
|
||||||
-t, --toggle toggle mute
|
-t, --toggle toggle mute
|
||||||
@ -177,28 +182,28 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then #if '__name__' == '__main__'
|
|||||||
case $1 in
|
case $1 in
|
||||||
-v|--verbose)
|
-v|--verbose)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
verbose && echo "Setting VERBOSE to true (VERBOSE=$VERBOSE)"
|
verbose && echo "Setting \$VERBOSE to true (\$VERBOSE=$VERBOSE)"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-c|--config)
|
-c|--config)
|
||||||
CONFIG_PATH="$2";
|
CONFIG_PATH="$2";
|
||||||
verbose && echo "Setting CONFIG_PATH to $2 (CONFIG_PATH=$CONFIG_PATH)"
|
verbose && echo "Setting \$CONFIG_PATH to $2 (\$CONFIG_PATH=$CONFIG_PATH)"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-n|--notification)
|
-n|--notification)
|
||||||
NOTIFICATION=1
|
NOTIFICATION_ENABLED=1
|
||||||
verbose && echo "Setting NOTIFICATION to true (NOTIFICATION=$NOTIFICATION)"
|
verbose && echo "Setting \$NOTIFICATION_ENABLED to true (\$NOTIFICATION_ENABLED=$NOTIFICATION_ENABLED)"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-N|--no-notification)
|
-N|--no-notification)
|
||||||
NOTIFICATION=0;
|
NOTIFICATION_ENABLED=0;
|
||||||
verbose && echo "Setting NOTIFICATION to false (NOTIFICATION=$NOTIFICATION)"
|
verbose && echo "Setting \$NOTIFICATION_ENABLED to false (\$NOTIFICATION_ENABLED=$NOTIFICATION_ENABLED)"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
verbose && echo "Looking at the argument"
|
verbose && echo "Looking at the argument '$@'"
|
||||||
case $1 in
|
case $1 in
|
||||||
-i|--increase)
|
-i|--increase)
|
||||||
verbose && echo "Detected -i or --increase, with argument '$2'"
|
verbose && echo "Detected -i or --increase, with argument '$2'"
|
||||||
@ -220,6 +225,14 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then #if '__name__' == '__main__'
|
|||||||
verbose && echo "Detected -s or --set-volume, with argument '$2'"
|
verbose && echo "Detected -s or --set-volume, with argument '$2'"
|
||||||
[[ -z "$2" ]] && echo "Error, missing value to set volume" 1>&2 && exit 1 || volume_set $2
|
[[ -z "$2" ]] && echo "Error, missing value to set volume" 1>&2 && exit 1 || volume_set $2
|
||||||
;;
|
;;
|
||||||
|
--set-min-volume)
|
||||||
|
verbose && echo "Detected --set-min-volume"
|
||||||
|
volume_set $VOLUME_MIN
|
||||||
|
;;
|
||||||
|
--set-max-volume)
|
||||||
|
verbose && echo "Detected --set-min-volume"
|
||||||
|
volume_set $VOLUME_MAX
|
||||||
|
;;
|
||||||
-m|--set-mute)
|
-m|--set-mute)
|
||||||
verbose && echo "Detected -m or --mute"
|
verbose && echo "Detected -m or --mute"
|
||||||
mute
|
mute
|
||||||
|
Loading…
Reference in New Issue
Block a user