This handler can be included into a Alfred 2 workflow based on bash scripts. It is meant to reduce the overhead when creating feedback XML and dealing with workflow preferences.
Download and put it into your workflow directory.
. workflowHandler.sh
# create feedback entries
# addResult "uid" "arg" "title" "subtitle" "icon" "valid" "autocomplete"
addResult "itemuid" "itemarg" "the item title" "the item subtitle" "icon.png" "yes" "autocomplete"
# get feedback xml
getXMLResults
<?xml version='1.0'?><items>
<item uid='itemuid' arg='itemarg' valid='yes' autocomplete='autocomplete'>
<title>the item title</title>
<subtitle>the item subtitle</subtitle>
<icon>icon.png</icon>
</item>
</items>
BUNDLEID=$(getBundleId)
echo "$BUNDLEID"
com.markokaestner.myworkflow
DATADIR=$(getDataDir)
echo "$DATADIR"
/Users/markokaestner/Library/Application Support/Alfred 2/Workflow Data/com.markokaestner.myworkflow
CACHEDIR=$(getCacheDir)
echo "$CACHEDIR"
/Users/markokaestner/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.markokaestner.myworkflow
# store volatile pref in default settings file
setPref "key" "value" 0
# store non-volatile pref in default settings file
setPref "key" "value" 1
# store volatile pref in specified file
setPref "key" "value" 0 "myprefs.txt"
# store non-volatile pref in specified file
setPref "key" "value" 1 "myprefs.txt"
# read volatile pref from default settings file
MYVAR=$(getPref "key" 0)
# read non-volatile pref from default settings file
MYVAR=$(getPref "key" 1)
# read volatile pref from specified file
MYVAR=$(getPref "key" 0 "myprefs.txt")
# read non-volatile pref from specified file
MYVAR=$(getPref "key" 1 "myprefs.txt")