From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16957 invoked by alias); 27 Sep 2012 23:13:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30697 Received: (qmail 5757 invoked from network); 27 Sep 2012 23:13:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1348787217; bh=HejJrZTGmbthgP80Q1yojAqIae2WEJWkmfBVItwe2xQ=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:From:To:Subject:Date:Message-ID; b=TS0qun+4RSY4IWjPjR/BRRxNrcOFFhcz81MuUQKDcRIqa+hT3PzayjIgNFmYtI1W2dcyRJjgoAVpWrF0HEw+FSDk/g7XL/yLIifgCB/DbbPu0Eic8ZCPOfXnqx3yx1jp+3hYNX0RLJj64VooLW7kfe4EfSpA+3IfLpfGoVTfpBs= X-Yahoo-Newman-Id: 901962.21069.bm@smtp128.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Uv8hlNYVM1liVTtS5gT1lRwCChpgrAIbU47n3dxkOWGmf8D iRhPbPzgBBBDX4SaRvr140qkAj9RpP0STwl_KqmKOmI7egeFqQvIk93Ny25p v9wV.veqdxoKKF4ZI.2otDcFBGU4uGoPgrV.1N6ZPJdNvK5a1uRwHQ8p3C51 pxm8U97LKUr226.X0HbFjkOA4FbGFHlZCZShm1ZlpFIL5c7pACnGmQRawq3w 11IOL0BF.w7aDdFXP6rPWaJkKRgEGACjhOIGDK.GJPP3PQrovKeonDd_wRYG ir4u83EY_5mUmKXhhdeamlYBYhvRYsGqfePmIJVAZ7ayunOgPdO9Xt9kUJFS MjthDHtfBSOp41J9c9QjCn6mdftBariusxnz5QWrMMt1beodOzHHD5N5._Vy e80saQL1.wz4OmUlGpx3a68b2Bg8wL3h39hwBovobB5EC62qiQrkQfr1.jCX cOITTwHrd8FEhVYM.455hDr8lyR8- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: completion for dbus-send and dbus-monitor Date: Fri, 28 Sep 2012 01:06:56 +0200 Message-ID: <29901.1348787216@thecus.kiddle.eu> This is a completion function for dbus. It could be improved in some areas such as automatically handling types of arguments to dbus methods but I'm not quite sure what the correct dbus-send syntax is for things like arrays of arrays and parsing the output with nested zsh expressions isn't much fun anyway. I've also not bothered too much about things like bus addresses that are rarely specified explicitly. Oliver Index: Completion/Unix/Command/_dbus =================================================================== RCS file: Completion/Unix/Command/_dbus diff -N Completion/Unix/Command/_dbus --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Unix/Command/_dbus 27 Sep 2012 22:58:50 -0000 @@ -0,0 +1,87 @@ +#compdef dbus-send dbus-monitor + +local curcontext="$curcontext" state line find end ret=1 +typeset -A opt_args +local -a suf introspect interfaces + +case $service in + dbus-send) + _arguments -A "--*" -C \ + '(--session)--system' '(--system)--session' \ + '--address=-:bus address:->addresses' \ + '--dest=-:connection:->connections' \ + '--print-reply=-::format:(literal)' \ + '--reply-timeout=-:timeout (ms)' \ + '--type=-:type:(method_call signal)' \ + ':object path:->objectpaths' \ + ':message name:->methods' \ + ':content:->contents' && ret=0 + ;; + dbus-monitor) + _arguments -A "--*" -C \ + '(--session)--system' '(--system)--session' \ + '--address=-:bus address:->addresses' \ + '(--profile)--monitor' '(--monitor)--profile' \ + '*:watch expression:->expressions' && ret=0 + ;; +esac + +case $state in + addresses) + compset -P '*;' + if compset -P '*='; then + _files && ret=0 + else + _message -e addresses address + fi + ;; + connections) + _wanted connections expl connection compadd ${=${(M)PREFIX:#*.*}:+-M 'r:|.=* r:|=*'} ${$(_call_program connections dbus-send ${opt_args[(I)--system]} --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames 2>/dev/null):#(array|\[|\])} ${$(_call_program connections dbus-send ${opt_args[(I)--system]} --print-reply=literal --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames 2>/dev/null):#(array|\[|\])} && ret=0 + ;; + objectpaths) + if [[ -prefix / ]]; then + compset -P ${PREFIX%%[^/]#} + _wanted objectpaths expl 'object path' compadd -qS/ ${${${(M)${(f)"$(_call_program objectpaths dbus-send --print-reply ${(M)words:#(--dest=|--system|--address=)*} ${${IPREFIX%/}:-/} org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null)"}:#*node name=[^/]##\"*}#*\"}%\"*} && ret=0 + else + _wanted objectpaths expl 'object path' compadd -S '/' -r '-=' '' && ret=0 + fi + ;; + methods) + introspect=( ${(M)${(f)"$(_call_program methods dbus-send --print-reply ${(M)words:#(--dest=|--system|--address=|/)*} org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null)"}:#*name=*} ) + interfaces=( ${${${(M)introspect:#*interface name=*}#*\"}%\"*} ) + _wanted interfaces expl interface compadd -qS. -M 'r:|.=* r:|=*' -a interfaces && ret=0 + if [[ $compstate[nmatches] != $#interfaces ]] && compset -P '*.'; then + find="*interface name=?${IPREFIX%.}??" + end=${interfaces[(i)${IPREFIX%.}]} + _wanted methods expl method compadd ${${${(M)${${introspect[${introspect[(i)$find]}+1,(in.end+1.)*interface name=*]}:#*interface name=*}:#*${${opt_args[--type]%_*}:-method} name=*}#*\"}%\"*} && ret=0 + fi + ;; + contents) + compset -S ':*' || suf=( -S : ) + while compset -P '(array|dict|variant):'; do + : + done + if compset -P '*:'; then + _message -e value 'value' + else + _alternative -O suf \ + 'containers:container:(array dict variant)' \ + 'types:type:(string double byte boolean objpath '${(j. .):-{,u}int{16,32,64}}\) && ret=0 + fi + ;; + expressions) + _values -w -s , 'expression' \ + 'type:message type:(signal method_call method_return error)' \ + 'sender:bus or name' \ + 'interface:interface' \ + 'member:member' \ + 'path:path' \ + 'path_namespace:path' \ + 'destination:unique name' \ + arg{0..9}:value \ + 'arg0namespace:namespace' \ + 'eavesdrop:eavesdropping:(true false)' && ret=0 + ;; +esac + +return ret