tools/gstreamer-completion: Updated to work with the binary registry

The original registry was in xml format (~/.gstreamer-*/registry.xml). A
binary registry format was added in 2007 (commit ebf0c9d3) and made the
default in 2008 (commit 3f39fd7e). In 0.10 you could still choose at
"configure" time to use the xml registry instead; in 1.0 the binary
registry is your only choice.

This change to gstreamer-completion should work with either format
because it parses the output of "gst-inspect" instead of reading the
registry file directly.

Note that _gst_launch no longer needs an explicit "return 0" because,
unlike the previous grep command, compgen always returns 0 (unless a
genuine error occurs).

Just like the previous implementation by David Schleef, this "only
completes names of features, but that's 90% of what I want it for."
This commit is contained in:
David Rothlisberger 2012-11-13 16:36:46 +00:00 committed by Stefan Sauer
parent a2170fc7b8
commit 271c707c45

View file

@ -2,26 +2,12 @@
# Put this in /etc/bash_completion.d/
#
_gst_launch()
{
local cur
_gst_launch() {
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "$(_gst_elements)" -- "$cur") )
} &&
complete -F _gst_launch -o default gst-launch-1.0
: ${GST_REGISTRY:=~/.gstreamer-1.0/registry.xml}
: ${GST_COMPLETE:=~/.gstreamer-1.0/complete}
if [ ! -f "${GST_REGISTRY}" ] ; then
return 0
fi
if [ ! -f "${GST_COMPLETE}" \
-o "${GST_REGISTRY}" -nt "${GST_COMPLETE}" ] ; then
sed -n 's/^..<name>\(.*\)<\/name>/\1/ p' ${GST_REGISTRY} >${GST_COMPLETE}
fi
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(grep ^$cur $GST_COMPLETE) )
return 0
_gst_elements() {
gst-inspect-1.0 | grep -v 'Total count' | awk -F': +' '{print $2}'
}
complete -F _gst_launch -o default gst-launch