Place Holder Projects Code
Bash MySQL JavaScript MySQL Quick Reference
Notes Documents Return of the Fed Login

Code

*More fully fledged applications can be found on the Projects page. The Bash page is dedicated to fully commented oneliners, and a MySQL quick reference is available here.



#!/bin/bash

# volume captured as precentage
# setting takes a decimal between 0,7
# 100% == 7, 0% == 0
inc=$(echo "100/7" | bc -l)

# Get the current vol:
cur_percent=$(osascript -e 'get volume settings' | grep -oE "[0-9]{1,3}" | head -1)
cur_v=$(echo "$cur_percent/$inc" | bc -l)

# Increment by .5, max 7:
new=$(echo "$cur_v + .5" | bc -l)
if (( $(echo "$new > 7" | bc -l) )); then
	new=7
fi

# Set new volume:
osascript -e 'set volume '$new

# Print change if 'quiet flag' not set:
if [[ $1 != "-q" ]]; then
	printf "%0.0f%% -> %0.0f%%\n" $(echo "$cur_v*$inc" | bc) $(echo "$new*$inc" | bc)
fi