mirror of
https://github.com/notwa/rc
synced 2024-07-01 03:07:13 -07:00
add argc-checking and don't rely on shell expansion
This commit is contained in:
parent
51e0ddc46f
commit
e46e3769d1
|
@ -3,8 +3,13 @@
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
# YES_BASH
|
# YES_BASH
|
||||||
|
|
||||||
MPV_STREAM_FLAGS="--quiet --loop-playlist=no --no-resume-playback --no-sub \
|
mpvs() { ### @- invoke mpv with some extra flags suited for streamed sources.
|
||||||
--no-initial-audio-sync --mc=0.02 --autosync=30"
|
mpv --quiet \
|
||||||
|
--loop-playlist=no --no-resume-playback \
|
||||||
|
--no-sub \
|
||||||
|
--no-initial-audio-sync --mc=0.02 --autosync=30 \
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Q: Why are these variables prefixed with _M_?
|
# Q: Why are these variables prefixed with _M_?
|
||||||
# A: I don't remember. :shobon:
|
# A: I don't remember. :shobon:
|
||||||
|
@ -19,6 +24,7 @@ _M_LESS_INSANE="$_M_PRE_EMPH,acompressor=threshold=0.0020:ratio=1.41:attack=1000
|
||||||
_M_NEO="equalizer=700:o:1.3:-5,equalizer=1200:o:1.3:-3,equalizer=1090:o:0.5:-5,equalizer=970:o:1.2:-10,equalizer=4100:o:0.3:-6"
|
_M_NEO="equalizer=700:o:1.3:-5,equalizer=1200:o:1.3:-3,equalizer=1090:o:0.5:-5,equalizer=970:o:1.2:-10,equalizer=4100:o:0.3:-6"
|
||||||
|
|
||||||
getladspa() {
|
getladspa() {
|
||||||
|
[ $# -eq 1 ] || { printf "%s\n" "$0: expected exactly one argument" >&2; return 1; }
|
||||||
REPLY=volume
|
REPLY=volume
|
||||||
if [ -e "/usr/lib/ladspa/${1}.so" ]; then
|
if [ -e "/usr/lib/ladspa/${1}.so" ]; then
|
||||||
REPLY="ladspa=f=${1}:p=${1}"
|
REPLY="ladspa=f=${1}:p=${1}"
|
||||||
|
@ -31,6 +37,7 @@ _M_LEVEL="$REPLY"
|
||||||
_nn="$(uname -n | tr A-Z a-z)"
|
_nn="$(uname -n | tr A-Z a-z)"
|
||||||
|
|
||||||
earphones() {
|
earphones() {
|
||||||
|
[ $# -eq 0 ] || { printf "%s\n" "$0: unexpected arguments" >&2; return 1; }
|
||||||
_M_PROCESS="lowpass=8000:p=1,$_M_KILL,alimiter=level_out=0.707"
|
_M_PROCESS="lowpass=8000:p=1,$_M_KILL,alimiter=level_out=0.707"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +46,7 @@ if [ "$_nn" = spectre ]; then
|
||||||
fi
|
fi
|
||||||
if [ "$_nn" = neobanshee ]; then
|
if [ "$_nn" = neobanshee ]; then
|
||||||
speakers() {
|
speakers() {
|
||||||
|
[ $# -eq 0 ] || { printf "%s\n" "$0: unexpected arguments" >&2; return 1; }
|
||||||
_M_PROCESS="highpass=311,$_M_KILL,$_M_NEO,alimiter=level_in=2"
|
_M_PROCESS="highpass=311,$_M_KILL,$_M_NEO,alimiter=level_in=2"
|
||||||
}
|
}
|
||||||
speakers
|
speakers
|
||||||
|
@ -47,6 +55,7 @@ if [ "$_nn" = banshee ]; then
|
||||||
getladspa crap_eq_const_T420
|
getladspa crap_eq_const_T420
|
||||||
_M_SPEAKERS="$REPLY"
|
_M_SPEAKERS="$REPLY"
|
||||||
speakers() {
|
speakers() {
|
||||||
|
[ $# -eq 0 ] || { printf "%s\n" "$0: unexpected arguments" >&2; return 1; }
|
||||||
_M_PROCESS="$_M_LEVEL,$_M_SPEAKERS,alimiter=level_in=0.5"
|
_M_PROCESS="$_M_LEVEL,$_M_SPEAKERS,alimiter=level_in=0.5"
|
||||||
}
|
}
|
||||||
speakers
|
speakers
|
||||||
|
@ -56,6 +65,7 @@ unset _nn
|
||||||
|
|
||||||
mpv_watch() { ### @-
|
mpv_watch() { ### @-
|
||||||
### watch something in mpv with a bunch of extra audio filtering crap.
|
### watch something in mpv with a bunch of extra audio filtering crap.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
pushd ~/play >/dev/null
|
pushd ~/play >/dev/null
|
||||||
local url="$1"; shift
|
local url="$1"; shift
|
||||||
mpv \
|
mpv \
|
||||||
|
@ -67,19 +77,16 @@ mpv_watch() { ### @-
|
||||||
|
|
||||||
mpv_stream() { ### @-
|
mpv_stream() { ### @-
|
||||||
### watch a stream in mpv with a bunch of extra audio filtering crap.
|
### watch a stream in mpv with a bunch of extra audio filtering crap.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
pushd ~/play >/dev/null
|
pushd ~/play >/dev/null
|
||||||
local url="$1"; shift
|
local url="$1"; shift
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
mpvs --af=lavfi="[$_M_PROCESS]" "$@" "$url"
|
||||||
# zsh syntax
|
|
||||||
mpv $=MPV_STREAM_FLAGS --af=lavfi="[$_M_PROCESS]" "$@" "$url"
|
|
||||||
else
|
|
||||||
mpv $MPV_STREAM_FLAGS --af=lavfi="[$_M_PROCESS]" "$@" "$url"
|
|
||||||
fi
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
twitch() { ### @-
|
twitch() { ### @-
|
||||||
### watch a twitch stream in mpv with a bunch of extra audio filtering crap.
|
### watch a twitch stream in mpv with a bunch of extra audio filtering crap.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
local user="$1"; shift
|
local user="$1"; shift
|
||||||
mpv_stream "http://twitch.tv/$user" "$@"
|
mpv_stream "http://twitch.tv/$user" "$@"
|
||||||
}
|
}
|
||||||
|
@ -90,6 +97,7 @@ yt() { ### @-
|
||||||
### remaining arguments are passed to mpv.
|
### remaining arguments are passed to mpv.
|
||||||
###
|
###
|
||||||
### there exist several variants for more specific use cases.
|
### there exist several variants for more specific use cases.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
local vid="$1"; shift
|
local vid="$1"; shift
|
||||||
[ -e "$vid" ] || [ "$vid" != "${vid#http}" ] || vid="ytdl://$vid"
|
[ -e "$vid" ] || [ "$vid" != "${vid#http}" ] || vid="ytdl://$vid"
|
||||||
mpv_watch "$vid" "$@"
|
mpv_watch "$vid" "$@"
|
||||||
|
@ -97,6 +105,7 @@ yt() { ### @-
|
||||||
|
|
||||||
ytg() { ### @-
|
ytg() { ### @-
|
||||||
### watch a youtube video. like `yt`, but with a preference for different formats.
|
### watch a youtube video. like `yt`, but with a preference for different formats.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
local vid="$1"; shift
|
local vid="$1"; shift
|
||||||
yt "$vid" --ytdl-format=22/95/300/best "$@"
|
yt "$vid" --ytdl-format=22/95/300/best "$@"
|
||||||
}
|
}
|
||||||
|
@ -104,22 +113,26 @@ ytg() { ### @-
|
||||||
ytll() { ### @-
|
ytll() { ### @-
|
||||||
### watch a stream on youtube in mpv, etcetera etcetera.
|
### watch a stream on youtube in mpv, etcetera etcetera.
|
||||||
### this is the low latency version that does not support seeking.
|
### this is the low latency version that does not support seeking.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
youtube-dl -q -f best "$1" -o - | mpv_stream - --no-ytdl
|
youtube-dl -q -f best "$1" -o - | mpv_stream - --no-ytdl
|
||||||
}
|
}
|
||||||
|
|
||||||
ytgll() { ### @-
|
ytgll() { ### @-
|
||||||
### watch a stream on youtube in mpv. like `ytll`, but with a preference for different formats.
|
### watch a stream on youtube in mpv. like `ytll`, but with a preference for different formats.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
youtube-dl -q -f 22/95/300/best "$1" -o - | mpv_stream - --no-ytdl
|
youtube-dl -q -f 22/95/300/best "$1" -o - | mpv_stream - --no-ytdl
|
||||||
}
|
}
|
||||||
|
|
||||||
ai() { # @-
|
ai() { # @-
|
||||||
# hai domo!
|
# hai domo!
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
yt "$@" --slang=en --sub-font='Tekton Pro' --sub-bold=yes \
|
yt "$@" --slang=en --sub-font='Tekton Pro' --sub-bold=yes \
|
||||||
--sub-font-size=60 --sub-border-color='#DD6180' --sub-margin-y=52
|
--sub-font-size=60 --sub-border-color='#DD6180' --sub-margin-y=52
|
||||||
}
|
}
|
||||||
|
|
||||||
asmr() { # @-
|
asmr() { # @-
|
||||||
# for your aural pleasure.
|
# for your aural pleasure.
|
||||||
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
_M_PROCESS="acompressor=threshold=0.001:ratio=1.33:attack=900:release=6000:makeup=6:knee=8:mix=0.9,alimiter" \
|
_M_PROCESS="acompressor=threshold=0.001:ratio=1.33:attack=900:release=6000:makeup=6:knee=8:mix=0.9,alimiter" \
|
||||||
yt "$@" --volume=90 --ytdl-format=251/300/best
|
yt "$@" --volume=90 --ytdl-format=251/300/best
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user