diff options
author | sinanmohd <sinan@firemail.cc> | 2023-11-04 19:27:28 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-11-04 19:27:34 +0530 |
commit | 8260316a1d3b9a0bc918988375782c019c1a81be (patch) | |
tree | f66e249182f84993adbf5d031abaecc19300418e /.local/bin/wobload | |
parent | 59bade9f01b352528f97db2e777d307659b1de8e (diff) |
bin/wobload: refactor
Diffstat (limited to '.local/bin/wobload')
-rwxr-xr-x | .local/bin/wobload | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/.local/bin/wobload b/.local/bin/wobload index 0d8b121..599024c 100755 --- a/.local/bin/wobload +++ b/.local/bin/wobload @@ -30,39 +30,38 @@ render() echo "${1%%.*}" > "$wobpipe" } -main() -{ - exe="$1" - shift +######## +# MAIN # +######## - if [ -z "$exe" ]; then - usage - exit - elif [ ! -p "$wobpipe" ]; then - err "$wobpipe: named pipe does not exist" - exit 1 - elif ! command -v "$exe" > /dev/null; then - err "${exe}: command not found" - exit 127 - fi +exe="$1" +shift - case "$exe" in - "wpctl") - wpctl "$@" +if [ -z "$exe" ]; then + usage + exit +elif [ ! -p "$wobpipe" ]; then + err "$wobpipe: named pipe does not exist" + exit 1 +elif ! command -v "$exe" > /dev/null; then + err "${exe}: command not found" + exit 127 +fi - data="$(wpctl get-volume "@DEFAULT_AUDIO_SINK@")" - render "$(echo "${data##* } * 100" | bc)" - ;; - "brightnessctl") - brightnessctl "$@" +case "$exe" in +"wpctl") + wpctl "$@" - data="$(brightnessctl info | grep -o '[0-9]*%')" - render "${data%\%}" - ;; - *) - err "${exe}: not implemented" - "$exe" "$@" - esac -} + data="$(wpctl get-volume "@DEFAULT_AUDIO_SINK@")" + render "$(echo "${data##* } * 100" | bc)" + ;; +"brightnessctl") + brightnessctl "$@" -main "$@" + data="$(brightnessctl info | grep -o '[0-9]*%')" + render "${data%\%}" + ;; +*) + err "${exe}: not implemented" + "$exe" "$@" +esac |