From 465c241cbb6fff4c12c35e02c6f32a9fd20b0921 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sat, 10 Jul 2021 00:48:14 -0400 Subject: [PATCH] volume script --- dotfiles-old/bin/volume | 58 ++++++++++++++++++++++++++++++++++++++ dotfiles-old/manifest_file | 1 + 2 files changed, 59 insertions(+) create mode 100755 dotfiles-old/bin/volume diff --git a/dotfiles-old/bin/volume b/dotfiles-old/bin/volume new file mode 100755 index 0000000..df439a3 --- /dev/null +++ b/dotfiles-old/bin/volume @@ -0,0 +1,58 @@ +#!/bin/sh + +argv0="$0" + +usage() { + printf "\ +Usage: %b {absolute,help,relative,status} [ARGUMENT...]\n" "$argv0" + printf "\ +Examples: + %b absolute 0 # mute sound output + %b help # print this help text + %b relative 4 # increase the volume by 4 units + %b relative -4 # decrease the volume by 4 units + %b status # print current volume +" "$argv0" "$argv0" "$argv0" "$argv0" "$argv0" + printf "\ +The options are matched with [char]*. So \"%b help\" +works the same as \"%b h\". + +" "$argv0" "$argv0" + exit 1 +} + +[ -n "$1" ] || usage + +case "$1" in +(a*) + case "$(uname)" in + (NetBSD) + audioctl -w play.gain=$1 >/dev/null + ;; + (*) unknown_system + esac + ;; +(h*) usage ;; +(r*) + case "$(uname)" in + (NetBSD) + # works. 9.2 STABLE 2021-07 + audioctl -w play.gain=$(( \ + $( \ + audioctl -a \ + | grep "play\.gain" \ + | cut -d '=' -f 2 \ + ) + $2)) >/dev/null + ;; + (*) unknown_system + esac + ;; +(s*) + case "$(uname)" in + (NetBSD) + audioctl -a | grep "play\.gain" | cut -d '=' -f 2 + ;; + (*) unknown_system + esac + ;; +esac diff --git a/dotfiles-old/manifest_file b/dotfiles-old/manifest_file index d797411..1c2d2b6 100644 --- a/dotfiles-old/manifest_file +++ b/dotfiles-old/manifest_file @@ -15,4 +15,5 @@ .config/i3status/config bin/data bin/displaym +bin/volume src/dmenu/config.h