dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit 7b5e052be03df2568f46af4264bc82d273ed98b1
parent 0abb52f489315364a01de20c516ebf540b90b249
Author: Paco Esteban <paco@onna.be>
Date:   Sat, 15 Sep 2018 17:09:46 +0200

volume control script for openbsd

Diffstat:
bin/bin/volume.sh | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)

diff --git a/bin/bin/volume.sh b/bin/bin/volume.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +ACTION="$1" + +function usage { + echo "$1 [up|down|mute]" >&2 +} + +function set_vol { + VOL=$(mixerctl -a |grep outputs.master= | cut -d'=' -f2 | cut -d',' -f1) + NEWVOL=$(expr $VOL $1 $2) + [ "$NEWVOL" -ge 255 ] && NEWVOL=255 + [ "$NEWVOL" -le 0 ] && NEWVOL=0 + mixerctl outputs.master="$NEWVOL,$NEWVOL" +} + +function toggle_mute { + CURRENT_STATUS=$(mixerctl -a |grep outputs.master.mute= | cut -d'=' -f2) + if [ "$CURRENT_STATUS" = "off" ]; then + MSET="on" + else + MSET="off" + fi + mixerctl outputs.master.mute="$MSET" +} + +if [ -z "$ACTION" ]; then + usage "$0" + exit 1 +fi + +case $ACTION in + up ) + set_vol "+" "2" + ;; + down ) + set_vol "-" "2" + ;; + mute ) + toggle_mute + ;; + * ) + usage "$0" + exit 1 + ;; +esac