home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / bluez < prev    next >
Encoding:
Text File  |  2010-11-16  |  10.2 KB  |  433 lines

  1. # bash completion for bluez utils
  2.  
  3. have hcitool && {
  4. _bluetooth_adresses()
  5. {
  6.     if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then
  7.         COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "$( hcitool scan | \
  8.             awk '/^\t/{print $1}' )" -- "$cur" ) )
  9.     fi
  10. }
  11.  
  12. _bluetooth_devices()
  13. {
  14.     COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "$( hcitool dev | \
  15.         awk '/^\t/{print $1}' )" -- "$cur" ) )
  16. }
  17.  
  18. _bluetooth_services()
  19. {
  20.     COMPREPLY=( $( compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG \
  21.         SAP NAP GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE \
  22.         UDITE SYNCML' -- "$cur" ) )
  23. }
  24.  
  25. _bluetooth_packet_types()
  26. {
  27.     COMPREPLY=( $( compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \
  28.         -- "$cur" ) )
  29. }
  30.  
  31. _hcitool()
  32. {
  33.     local cur prev split=false arg
  34.  
  35.     COMPREPLY=()
  36.     _get_comp_words_by_ref cur prev
  37.  
  38.     _split_longopt && split=true
  39.  
  40.     case $prev in
  41.         -i)
  42.             _bluetooth_devices
  43.             return 0;
  44.             ;;
  45.         --role)
  46.             COMPREPLY=( $( compgen -W 'm s' -- "$cur" ) )
  47.             return 0;
  48.             ;;
  49.         --pkt-type)
  50.             _bluetooth_packet_types
  51.             return 0;
  52.             ;;
  53.     esac
  54.  
  55.     $split && return 0
  56.  
  57.     _get_first_arg
  58.     if [ -z $arg ]; then
  59.         if [[ "$cur" == -* ]]; then
  60.             COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
  61.         else
  62.             COMPREPLY=( $( compgen -W 'dev inq scan name info \
  63.                 spinq epinq cmd con cc dc sr cpt rssi lq tpl \
  64.                 afh lst auth enc key clkoff clock' -- "$cur" ) )
  65.         fi
  66.     else
  67.         case $arg in
  68.             name|info|dc|rssi|lq|afh|auth|key|clkoff|lst)
  69.                 _count_args
  70.                 if [ $args -eq 2 ]; then
  71.                     _bluetooth_adresses
  72.                 fi
  73.                 ;;
  74.             cc)
  75.                 if [[ "$cur" == -* ]]; then
  76.                     COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) )
  77.                 else
  78.                     _count_args
  79.                     if [ $args -eq 2 ]; then
  80.                         _bluetooth_adresses
  81.                     fi
  82.                 fi
  83.                 ;;
  84.             sr)
  85.                 _count_args
  86.                 if [ $args -eq 2 ]; then
  87.                     _bluetooth_adresses
  88.                 else
  89.                     COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) )
  90.                 fi
  91.                 ;;
  92.             cpt)
  93.                 _count_args
  94.                 if [ $args -eq 2 ]; then
  95.                     _bluetooth_adresses
  96.                 else
  97.                     _bluetooth_packet_types
  98.                 fi
  99.                 ;;
  100.             tpl|enc|clock)
  101.                 _count_args
  102.                 if [ $args -eq 2 ]; then
  103.                     _bluetooth_adresses
  104.                 else
  105.                     COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
  106.                 fi
  107.                 ;;
  108.         esac
  109.     fi
  110. }
  111. complete -F _hcitool hcitool
  112.  
  113. _sdptool()
  114. {
  115.     local cur prev split=false
  116.  
  117.     COMPREPLY=()
  118.     _get_comp_words_by_ref cur prev
  119.  
  120.     _split_longopt && split=true
  121.  
  122.     case $prev in
  123.         --bdaddr)
  124.             _bluetooth_adresses
  125.             return 0;
  126.             ;;
  127.     esac
  128.  
  129.     $split && return 0
  130.  
  131.     _get_first_arg
  132.     if [ -z $arg ]; then
  133.         if [[ "$cur" == -* ]]; then
  134.             COMPREPLY=( $( compgen -W '--help' -- "$cur" ) )
  135.         else
  136.             COMPREPLY=( $( compgen -W 'search browse records add \
  137.                 del get setattr setseq' -- "$cur" ) )
  138.         fi
  139.     else
  140.         case $arg in
  141.             search)
  142.                 if [[ "$cur" == -* ]]; then
  143.                     COMPREPLY=( $( compgen -W '--bdaddr \
  144.                         --tree --raw --xml' -- "$cur" ) )
  145.                 else
  146.                     _bluetooth_services
  147.                 fi
  148.                 ;;
  149.             browse|records)
  150.                 if [[ "$cur" == -* ]]; then
  151.                     COMPREPLY=( $( compgen -W '--tree --raw --xml' -- "$cur" ) )
  152.                 else
  153.                     _bluetooth_adresses
  154.                 fi
  155.                 ;;
  156.             add)
  157.                 if [[ "$cur" == -* ]]; then
  158.                     COMPREPLY=( $( compgen -W '--handle --channel' -- "$cur" ) )
  159.                 else
  160.                     _bluetooth_services
  161.                 fi
  162.                 ;;
  163.             get)
  164.                 if [[ "$cur" == -* ]]; then
  165.                     COMPREPLY=( $( compgen -W '--bdaddr \
  166.                         --tree --raw --xml' -- "$cur" ) )
  167.                 fi
  168.                 ;;
  169.         esac
  170.     fi
  171. }
  172. complete -F _sdptool sdptool
  173.  
  174. _l2ping()
  175. {
  176.     local cur prev
  177.  
  178.     COMPREPLY=()
  179.     _get_comp_words_by_ref cur prev
  180.  
  181.     case $prev in
  182.         -i)
  183.             _bluetooth_devices
  184.             return 0;
  185.             ;;
  186.     esac
  187.  
  188.     if [[ "$cur" == -* ]]; then
  189.         COMPREPLY=( $( compgen -W '-i -s -c -t -f -r' -- "$cur" ) )
  190.     else
  191.         _bluetooth_adresses
  192.     fi
  193.  
  194. }
  195. complete -F _l2ping l2ping
  196.  
  197. _rfcomm()
  198. {
  199.     local cur prev
  200.  
  201.     COMPREPLY=()
  202.     _get_comp_words_by_ref cur prev
  203.  
  204.     case $prev in
  205.         -f|--config)
  206.             _filedir
  207.             return 0;
  208.             ;;
  209.         -i)
  210.             _bluetooth_devices
  211.             _bluetooth_adresses
  212.             return 0;
  213.             ;;
  214.     esac
  215.  
  216.     _get_first_arg
  217.     if [ -z $arg ]; then
  218.         if [[ "$cur" == -* ]]; then
  219.             COMPREPLY=( $( compgen -W '--help -a --raw \
  220.                 --config -i --auth --encrypt --secure --master' -- "$cur" ) )
  221.         else
  222.             COMPREPLY=( $( compgen -W 'show connect listen watch \
  223.                 bind release' -- "$cur" ) )
  224.         fi
  225.     else
  226.         _count_args
  227.         if [ $args -eq 2 ]; then
  228.             _bluetooth_devices
  229.         else
  230.             case $arg in
  231.                 connect|bind)
  232.                     if [ $args -eq 3 ]; then
  233.                         _bluetooth_adresses
  234.                     fi
  235.                     ;;
  236.             esac
  237.         fi
  238.     fi
  239. }
  240. complete -F _rfcomm rfcomm
  241.  
  242. _ciptool()
  243. {
  244.     local cur prev
  245.  
  246.     COMPREPLY=()
  247.     _get_comp_words_by_ref cur prev
  248.  
  249.     case $prev in
  250.         -i)
  251.             _bluetooth_devices
  252.             _bluetooth_adresses
  253.             return 0;
  254.             ;;
  255.     esac
  256.  
  257.     _get_first_arg
  258.     if [ -z $arg ]; then
  259.         if [[ "$cur" == -* ]]; then
  260.             COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
  261.         else
  262.             COMPREPLY=( $( compgen -W 'show search connect release \
  263.                 loopback' -- "$cur" ) )
  264.         fi
  265.     else
  266.         case $arg in
  267.             connect|release|loopback)
  268.                 _count_args
  269.                 if [ $args -eq 2 ]; then
  270.                     _bluetooth_adresses
  271.                 fi
  272.                 ;;
  273.         esac
  274.     fi
  275. }
  276. complete -F _ciptool ciptool
  277.  
  278. _dfutool()
  279. {
  280.     local cur prev
  281.  
  282.     COMPREPLY=()
  283.     _get_comp_words_by_ref cur prev
  284.  
  285.     case $prev in
  286.         -d|--device)
  287.             _bluetooth_devices
  288.             return 0;
  289.             ;;
  290.     esac
  291.  
  292.     if [[ "$cur" == -* ]]; then
  293.         COMPREPLY=( $( compgen -W '--help --device' -- "$cur" ) )
  294.     else
  295.         _count_args
  296.         case $args in
  297.             1)
  298.                 COMPREPLY=( $( compgen -W 'verify modify \
  299.                     upgrade archive' -- "$cur" ) )
  300.                 ;;
  301.             2)
  302.                 _filedir
  303.                 ;;
  304.         esac
  305.     fi
  306. }
  307. complete -F _dfutool dfutool
  308.  
  309. _hciconfig()
  310. {
  311.     local cur
  312.  
  313.     COMPREPLY=()
  314.     _get_comp_words_by_ref cur
  315.  
  316.     _get_first_arg
  317.     if [ -z $arg ]; then
  318.         if [[ "$cur" == -* ]]; then
  319.             COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) )
  320.         else
  321.             COMPREPLY=( $( compgen -W 'up down reset rstat auth \
  322.                 noauth encrypt noencrypt secmgr nosecmgr \
  323.                 piscan noscan iscan pscan ptype name class \
  324.                 voice iac inqmode inqdata inqtype inqparams \
  325.                 pageparms pageto afhmode aclmtu scomtu putkey \
  326.                 delkey commands features version revision lm' \
  327.                 -- "$cur" ) )
  328.         fi
  329.     else
  330.         case $arg in
  331.             putkey|delkey)
  332.                 _count_args
  333.                 if [ $args -eq 2 ]; then
  334.                     _bluetooth_adresses
  335.                 fi
  336.                 ;;
  337.             lm)
  338.                 _count_args
  339.                 if [ $args -eq 2 ]; then
  340.                     COMPREPLY=( $( compgen -W 'MASTER \
  341.                         SLAVE NONE ACCEPT' -- "$cur" ) )
  342.                 fi
  343.                 ;;
  344.             ptype)
  345.                 _count_args
  346.                 if [ $args -eq 2 ]; then
  347.                     _bluetooth_packet_types
  348.                 fi
  349.                 ;;
  350.         esac
  351.     fi
  352. }
  353. complete -F _hciconfig hciconfig
  354.  
  355. _hciattach()
  356. {
  357.     local cur
  358.  
  359.     COMPREPLY=()
  360.     _get_comp_words_by_ref cur
  361.  
  362.     if [[ "$cur" == -* ]]; then
  363.         COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) )
  364.     else
  365.         _count_args
  366.         case $args in
  367.             1)
  368.                 COMPREPLY=( $( printf '%s\n' /dev/tty* ) )
  369.                 COMPREPLY=( $( compgen -W '${COMPREPLY[@]} \
  370.                     ${COMPREPLY[@]#/dev/}' -- "$cur" ) )
  371.                 ;;
  372.             2)
  373.                 COMPREPLY=( $( compgen -W 'any ericsson digi \
  374.                     xircom csr bboxes swave bcsp 0x0105 \
  375.                     0x080a 0x0160 0x0002' -- "$cur" ) )
  376.                 ;;
  377.             3)
  378.                 COMPREPLY=( $( compgen -W '9600 19200 38400 \
  379.                     57600 115200 230400 460800 921600' -- "$cur" ) )
  380.                 ;;
  381.             4)
  382.                 COMPREPLY=( $( compgen -W 'flow noflow' -- "$cur" ) )
  383.                 ;;
  384.             5)
  385.                 _bluetooth_adresses
  386.                 ;;
  387.         esac
  388.     fi
  389.  
  390. }
  391. complete -F _hciattach hciattach
  392.  
  393. _hid2hci()
  394. {
  395.     local cur
  396.  
  397.     COMPREPLY=()
  398.     _get_comp_words_by_ref cur
  399.  
  400.     if [[ "$cur" == -* ]]; then
  401.         COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \
  402.             --tohid' -- "$cur" ) )
  403.     fi
  404. }
  405. complete -F _hid2hci hid2hci
  406.  
  407. _avctrl()
  408. {
  409.     local cur
  410.  
  411.     COMPREPLY=()
  412.     _get_comp_words_by_ref cur
  413.  
  414.     if [[ "$cur" == -* ]]; then
  415.         COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) )
  416.     else
  417.         _count_args
  418.         if [ $args -eq 1 ]; then
  419.             COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) )
  420.         fi
  421.     fi
  422. }
  423. complete -F _avctrl avctrl
  424. }
  425.  
  426. # Local variables:
  427. # mode: shell-script
  428. # sh-basic-offset: 4
  429. # sh-indent-comment: t
  430. # indent-tabs-mode: nil
  431. # End:
  432. # ex: ts=4 sw=4 et filetype=sh
  433.