-
-
Save git2358/de32e4e9883a104e190b667ad31fcc7d to your computer and use it in GitHub Desktop.
Shell functions to manage OpenEmu shaders. Copy into your .zshrc file. Requires fzf. Not tested in bash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OpenEmu shader functions. Requires fzf. | |
function oeshader.search { | |
defaults find videoShader.openemu | grep $@ | |
} | |
function oeshader.copy { | |
local source=`oeshader.ls ${@:-1} | fzf --header="Select source:"` | |
if [[ -n $source ]]; then | |
oeshader.search -oE "system\.[a-z0-9]*" | sort -u | | |
fzf -m --header="Apply settings from \"${source##*.}\"." | | |
while read -r k; do | |
defaults write org.openemu.OpenEmu videoShader.openemu.$k.${source##*.}.params\ | |
-string `defaults read org.openemu.OpenEmu videoShader.openemu.$source.params` | |
echo "added $k.${source##*.}" | |
done | |
fi | |
} | |
function oeshader.clear { | |
oeshader.ls ${@:-1} | fzf -m --header="Clear item(s):" | | |
while read -r k; do | |
defaults delete org.openemu.OpenEmu videoShader.openemu.$k.params | |
echo "cleared $k" | |
done | |
} | |
function oeshader.ls { | |
local i=${@:-1} | |
local options=( system preset \(preset\|system\) ) | |
oeshader.search --color=never -oE "$options[$i](\.[^.]*){2}" | |
} | |
function oeshader.ls-all { | |
oeshader.ls 3 | |
} | |
function oeshader.ls-preset { | |
oeshader.ls 2 | |
} | |
function oeshader.apply-preset { | |
oeshader.copy 2 | |
} | |
# Optionally pass in the label. | |
# No validation involved. Stick to alphanumeric characters and spaces. Dot's are a big no no. | |
function oeshader.add-preset { | |
local source=`oeshader.ls 3 | fzf --header="Select source:"` | |
local k=${@:-default} | |
if [[ -n $source ]]; then | |
defaults write org.openemu.OpenEmu videoShader.openemu.preset.$k.${source##*.}.params\ | |
-string `defaults read org.openemu.OpenEmu videoShader.openemu.$source.params` | |
echo "added preset.$k.${source##*.}" | |
fi | |
} | |
function oeshader.clear-preset { | |
oeshader.clear 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment