From 271c707c45a7d46368eedba4f0d0539834b6a72a Mon Sep 17 00:00:00 2001 From: David Rothlisberger Date: Tue, 13 Nov 2012 16:36:46 +0000 Subject: [PATCH] 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." --- tools/gstreamer-completion | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/tools/gstreamer-completion b/tools/gstreamer-completion index dec7db1af2..5401af006c 100644 --- a/tools/gstreamer-completion +++ b/tools/gstreamer-completion @@ -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>/\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 -