PNG  IHDR  8] PLTE S =tRNS   PNG  IHDR  8] PLTE S =tRNS   REDROOM
PHP 7.4.33
Preview: _busctl Size: 9.36 KB
/usr/share/zsh/site-functions/_busctl

#compdef busctl
# SPDX-License-Identifier: LGPL-2.1-or-later

# busctl(1) completion                               -*- shell-script -*-
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# systemd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <https://www.gnu.org/licenses/>.

(( $+functions[_busctl_commands] )) || _busctl_commands()
{
    local -a _busctl_cmds
    _busctl_cmds=(
        "list:List bus names"
        "status:Show bus service, process or bus owner credentials"
        "monitor:Show bus traffic"
        "capture:Capture bus traffic"
        "tree:Show object tree of service"
        "introspect:Introspect object"
        "call:Call a method"
        "get-property:Get property value"
        "set-property:Set property value"
    )
    if (( CURRENT == 1 )); then
        _describe -t commands 'busctl command' _busctl_cmds || compadd "$@"
    else
        local curcontext="$curcontext"
        cmd="${${_busctl_cmds[(r)$words[1]:*]%%:*}}"
        curcontext="${curcontext%:*:*}:busctl-${cmd}:"
        if (( $+functions[_busctl_$cmd] )); then
            _busctl_$cmd
        else
            _message "no more options"
        fi
    fi
}

__busctl() {
    busctl $_bus_address --no-pager --no-legend "$@" 2>/dev/null
}

__dbus_matchspec() {
    # https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing
    _values -s, 'rules' \
        'type[Match on message type]:type:(signal method_call method_return error)' \
        'eavesdrop[Include unicast messages]:bool:(true false)' \
        'sender[Match messages sent by a particular sender]:sender:{compadd $(_busctl_get_service_names)}'\
        'interface[Match messages sent over or to a particular interface]:interface' \
        'member[Match messages which have the given method or signal name]:member' \
        'path[Match messages which are sent from or to the given object]:path' \
        'path_namespace[Match messages which are sent from or to the given namespace]:namespace' \
        'destination[Match messaged sent to the given unique name]:unique name:{compadd $(_busctl_get_unique_names)}'
}

(( $+functions[_busctl_get_json] )) || _busctl_get_json()
{
    local -a _json_forms
    _json_forms=( $(__busctl --json=help; echo help) )
    _values 'format' $_json_forms
}

(( $+functions[_busctl_get_service_names] )) || _busctl_get_service_names()
{
    local -a bus_names
    bus_names=( $(__busctl call \
        "org.freedesktop.DBus"  \
        "/org/freedesktop/DBus" \
        "org.freedesktop.DBus"  \
        ListNames) )
    echo ${(Q)bus_names[3,-1]}
}

(( $+functions[_busctl_get_unique_names] )) || _busctl_get_unique_names()
{
    local -a bus_names
    local NAME OTHER
    __busctl --unique list |
    while read NAME OTHER; do
        echo $NAME
    done
}

(( $+functions[_busctl_get_objects] )) || _busctl_get_objects()
{
    local -a objects
    local name="$1"
    objects=($(__busctl --list tree $name ))
    echo $objects
}

(( $+functions[_busctl_get_interfaces] )) || _busctl_get_interfaces()
{
    local NAME TYPE OTHER
    __busctl introspect "$1" "$2" |
    while read NAME TYPE OTHER; do
        if [[ ${TYPE} == "interface" ]]; then
            echo ${NAME}
        fi
    done
}

(( $+functions[_busctl_get_members] )) || _busctl_get_members()
{
    local member="$4"
    local required="$5"
    local NAME TYPE SIGNATURE VALUE FLAGS
    __busctl introspect "$1" "$2" "$3" |
    while read NAME TYPE SIGNATURE VALUE FLAGS; do
        [[ -z "$member" || ${TYPE} == "$member" ]] &&
        [[ -z "$required" || ${${(s: :)FLAGS}[-1]} == "$required" ]] &&
        echo ${NAME#.}
    done
}

(( $+functions[_busctl_get_signature] )) || _busctl_get_signature()
{
    local NAME TYPE SIGNATURE VALUE FLAGS
    __busctl introspect "$1" "$2" "$3" |
    while read NAME TYPE SIGNATURE VALUE FLAGS; do
        if [[ ${NAME#.} == "$4" ]]; then
            [[ ${SIGNATURE} != "-" ]] && echo ${SIGNATURE}
        fi
    done
}

(( $+functions[_busctl_status] )) || _busctl_status()
{
    local expl
    _wanted busname expl 'busname' compadd "$@" - $(_busctl_get_service_names)
}

(( $+functions[_busctl_monitor] )) || _busctl_monitor()
{
    local expl
    _wanted busname expl 'busname' compadd "$@" - $(_busctl_get_service_names)
}

(( $+functions[_busctl_tree] )) || _busctl_tree()
{
    local expl
    _wanted busname expl 'busname' compadd "$@" - $(_busctl_get_service_names)
}

(( $+functions[_busctl_introspect] )) || _busctl_introspect()
{
    local expl
    case $CURRENT in
        2)
            _wanted busname expl 'busname' \
            compadd "$@" - $(_busctl_get_service_names)
            ;;
        3)
            _wanted path expl 'path' \
            compadd "$@" - $(_busctl_get_objects $words[2])
            ;;
        4)
            _wanted interface expl 'interface' \
            compadd "$@" - $(_busctl_get_interfaces $words[2,3])
            ;;
        *)
            _message "no more options"
    esac
}

(( $+functions[_busctl_call] )) || _busctl_call()
{
    local expl
    case $CURRENT in
        2)
            _wanted busname expl 'busname' \
            compadd "$@" - $(_busctl_get_service_names)
            ;;
        3)
            _wanted path expl 'path' \
            compadd "$@" - $(_busctl_get_objects $words[2])
            ;;
        4)
            _wanted interface expl 'interface' \
            compadd "$@" - $(_busctl_get_interfaces $words[2,3])
            ;;
        5)
            _wanted method expl 'method' \
            compadd "$@" - $(_busctl_get_members $words[2,4] "method")
            ;;
        6)
            compadd "$@" - $(_busctl_get_signature $words[2,5])
            ;;
        *)
            _message "no more options"
    esac
}

(( $+functions[_busctl_get-property] )) || _busctl_get-property()
{
    local expl
    case $CURRENT in
        2)
            _wanted busname expl 'busname' \
            compadd "$@" - $(_busctl_get_service_names)
            ;;
        3)
            _wanted path expl 'path' \
            compadd "$@" - $(_busctl_get_objects $words[2])
            ;;
        4)
            _wanted interface expl 'interface' \
            compadd "$@" - $(_busctl_get_interfaces $words[2,3])
            ;;
        5)
            _wanted property expl 'property' \
            compadd "$@" - $(_busctl_get_members $words[2,4] "property")
            ;;
        *)
            _message "no more options"
    esac
}

(( $+functions[_busctl_set-property] )) || _busctl_set-property()
{
    local expl
    case $CURRENT in
        2)
            _wanted busname expl 'busname' \
            compadd "$@" - $(_busctl_get_service_names)
            ;;
        3)
            _wanted path expl 'path' \
            compadd "$@" - $(_busctl_get_objects $words[2])
            ;;
        4)
            _wanted interface expl 'interface' \
            compadd "$@" - $(_busctl_get_interfaces $words[2,3])
            ;;
        5)
            _wanted property expl 'property' \
            compadd "$@" - $(_busctl_get_members $words[2,4] "property" "writable")
            ;;
        6)
            compadd "$@" - $(_busctl_get_signature $words[2,5])
            ;;
        *)
            _message "no more options"
    esac
}

local -a _modes; _modes=("--user" "--system")
# Use the last mode (they are exclusive and the last one is used).
local _bus_address=${${words:*_modes}[(R)(${(j.|.)_modes})]}
local curcontext=$curcontext state line
_arguments \
    {-h,--help}'[Prints a short help text and exits.]' \
    '--version[Prints a short version string and exits.]' \
    '--no-pager[Do not pipe output into a pager]' \
    '--no-legend[Do not show the headers and footers]' \
    '--system[Connect to system manager]' \
    '--user[Connect to user service manager]' \
    {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
    {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
    '--address=[Connect to the bus specified by address]:address' \
    '--show-machine[Show machine ID column in list]' \
    '--unique[Only show unique names]' \
    '--acquired[Only show acquired names]' \
    '--activatable[Only show activatable names]' \
    '--match=[Only show matching messages]:match:__dbus_matchspec' \
    '--list[Do not show tree, but simple object path list]' \
    {-q,--quiet}'[Do not show method call reply]'\
    '--verbose[Show result values in long format]' \
    '--json=[Show result values in long format]:format:_busctl_get_json' \
    '-j[Show pretty json in interactive sessions, short json otherwise]' \
    '--expect-reply=[Expect a method call reply]:boolean:(1 0)' \
    '--auto-start=[Auto-start destination service]:boolean:(1 0)' \
    '--allow-interactive-authorization=[Allow interactive authorization for operation]:boolean:(1 0)' \
    '--timeout=[Maximum time to wait for method call completion]:timeout (seconds)' \
    '--augment-creds=[Extend credential data with data read from /proc/$PID]:boolean:(1 0)' \
    '*::busctl command:_busctl_commands'

Directory Contents

Dirs: 0 × Files: 28

Name Size Perms Modified Actions
2.84 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
9.36 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
6.18 KB lrw-r--r-- 2024-08-12 18:00:48
Edit Download
1.89 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
14.58 KB lrw-r--r-- 2026-01-28 08:27:23
Edit Download
20.25 KB lrw-r--r-- 2026-03-10 23:36:54
Edit Download
643 B lrw-r--r-- 2024-04-17 17:19:24
Edit Download
2.73 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
7.03 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
779 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
8.18 KB lrw-r--r-- 2021-12-13 03:43:13
Edit Download
3.68 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
6.25 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
120 B lrw-r--r-- 2026-05-05 09:12:24
Edit Download
128 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
505 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
318 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
263 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
19.50 KB lrw-r--r-- 2026-05-05 15:47:58
Edit Download
3.76 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
5.50 KB lrw-r--r-- 2026-05-05 15:44:27
Edit Download
633 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
1.15 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
330 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
4.25 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
744 B lrw-r--r-- 2022-10-31 18:59:18
Edit Download
2.00 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download
8.06 KB lrw-r--r-- 2022-10-31 18:59:18
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
 !"#$%&'(()*+,-./00123456789 t\ wIDATx ]ys  47Y ƒ -  "  Rv  < f{Ɛ $k l L > L  ~h^ 1  [  r G t& h  l F z3O Y ! p A(_g̷ E8 )S 8 c  Kb"z ~ 5 J xAL WU <  *  5 m;W a pB h ~P J 2 3 6 ҙ .Ƹ P i  4g F R L P ΪK/D  M v (a3 k J Œ4N5* SH ` SdJ z  O J Xՠ V>u ߱ BE&L b2 ?2` tX+  c CB A$ i b C ĀMB E : /  # Dx &l =q Ty  0 \p I ( L Ǎ { e 4k ;`u^ヲ eP!( d {  )T A 8 O;Ě n >;s6 !  :Nx `[S D HU ~ q›J F} a g*D 49 / pn k h (t 8NxƐF _!r չ7 ZR R׷ q/5") Ӎ NY 0 x sZ!   o  fu  ,  K"$ ? pg  㕣=  1» {h " fh7    y  } € +7  $ y " X —ą - G P u 4 m >J 5 L =V ' ^@I p ?MS xЌ XV P ! h "C NS9B8̢ ]!K  e   zA , ӏkbY  !< XQ ٿyS| *" f { w  4@[S <  # 0 ! js [m  =,~ o "ݎ DHf Wo $ g ! Vԅ t mB /y Wf V4񺍸 c+@x?  B ~u " xUN e 0 BĂ) ~J pz! 7y6]l Ԥ@ P a< O /DHC `≻  N m"$  0ObB }{ x AO FCG D R ^ "B  { WDH  UR l@ T #  +"d T ; 0 i  D}. 7 ` ' ] w rE &S i ƕiTD EL P _ u h $ Ա FG wVD G L R Zf ' .!] J /ZR oGЍs Mr Ĥ ʬ 3 Q [3 cL ` ^ p + ( F;# B 5 '  2Y f [  ϶R0e }  E 7 6M aۮ H <& n % L] E}Up x紉, Uw' Q  Ǯշo k ވۙ 0N94 VX5 xEDE l D #֤ } C o )W :  ^ s 9  bRf iX5u ཱི 4 :[  T 1. | [E 2ؽ Iy\ : o x K G 5 ylP ' uK E ftb/i[3 .g _  [3M n G, #NwQ5~  ؚ) | n =Ц"x qg gB ` 듘 ~ x w ? ? R~  _ u. &VQ K˻   H C ( TN˄+ `C dA nB׭ D 3"Z G ê ^k H_ /- ~ " R_  .8 Z_ 6@ o  xg  uP ? 3լ @7AM!  E7^ - =V L  x  g-D0  CtmW 7  O  G _ WD0 g C  w1 r d w : a | \  *" f nֳ ^ H# f L ` Z ۽hV  }S F r0Ù Bć5r] @! NL iQ]{s^=4 d  WD  "  "   M; t" 8 5 e dL| "-*st" ) SWD ?R[S e ooF  20.D ? bo =) A i o d ģ ZҰaO @E =) i D a &ܟa CϞ y6 ,<%{^x%{f8? `iw^ ?/ M * IEND B`