summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE11
-rw-r--r--README.md26
-rwxr-xr-xvolsv38
3 files changed, 75 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..3d547ec
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,11 @@
+Copyright 2020-2021 Zachary Smith
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b0dc96f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,26 @@
+# Volsv
+
+#### What is it?
+
+Volsv is a POSIX-compliant shell script I wrote in 2020, and have been modifying since. Presently, it supports:
+
+- Increasing volume
+- Decreasing volume
+- Toggling the interface mute
+- Toggling the microphone mute\*
+
+in both pulseaudio and ALSA\*. Once I get OpenBSD and FreeBSD up and running, I will add those sound options too.
+
+It depends on:
+
+- pamixer (pulseaudio)
+- amixer (alsa)
+- pgrep (with the -x command, standard in BSD and \*/Linux systems)
+
+#### But *why* though?
+
+I made volsv so that I could use it with keybindings to control the volume, regardless of whether or not I was running pulseaudio, since I dislike pulseaudio and tend to avoid it when possible. This means I can have a consistent keybinding, whether or not I'm using it. Additionally, this would give me less keybindings to have to port to OpenBSD, which I occasionally install from time to time, although I haven't booted into it since I started writing this script. Additionally, it has provided a fun learning experience as I learn to write scripts.
+
+
+
+\*Volsv does not yet support muting the microphone in ALSA.
diff --git a/volsv b/volsv
new file mode 100755
index 0000000..16e3ce2
--- /dev/null
+++ b/volsv
@@ -0,0 +1,38 @@
+#!/bin/sh
+# print error message
+printerror () {
+ echo "$1 is not a recognized command or flag"
+}
+# if pulseaudio
+pulsesv () {
+ case "$1" in
+ "up" | "-i") pamixer -i 5 ;;
+ "down" | "-d") pamixer -d 5 ;;
+ "toggle" | "-t") pamixer -t ;;
+ "mic" | "-m") pamixer --source 1 -t ;;
+ "getm" | "-g") ;;
+ *) printerror "$1" ;;
+ esac
+}
+# if alsa
+alsasv () {
+ case "$1" in
+ "up" | "-i") amixer sset Master 5%+ ;;
+ "down" | "-d") amixer sset Master 5%- ;;
+ "toggle" | "-t") amixer sset Master toggle ;;
+ "getm" | "-g") ;;
+ *) printerror "$1" ;;
+ esac
+}
+#Search input for
+echo "$@" | grep -q ' *-h *' && echo \
+"Volsv is Free software. You can use it for any purpose, but I make no guerantee about its usability or fitness "\
+"for any particular purpose. You are also free to redistribute, modify, and distribute your modifications to "\
+"volsv. Volsv is distributed under the BSD 3-Clause license to ensure full license compatibility with GNU, "\
+"Linux, and BSD operating systems. A copy of this license is included in the repository." && exit
+
+for i in $@; do
+ pgrep -x pulseaudio >/dev/null && pulsesv $1 || alsasv $1
+ pgrep -x dwmblocks >/dev/null && pkill -RTMIN+10 dwmblocks
+ pgrep -x dwmbar >/dev/null && dwmbar-signal volume
+done