From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14663 invoked from network); 30 Sep 2006 20:59:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Sep 2006 20:59:05 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 96566 invoked from network); 30 Sep 2006 20:58:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Sep 2006 20:58:57 -0000 Received: (qmail 20728 invoked by alias); 30 Sep 2006 20:58:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22794 Received: (qmail 20719 invoked from network); 30 Sep 2006 20:58:55 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Sep 2006 20:58:55 -0000 Received: (qmail 96353 invoked from network); 30 Sep 2006 20:58:54 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 30 Sep 2006 20:58:53 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id A563D70055; Sat, 30 Sep 2006 16:58:50 -0400 (EDT) Date: Sat, 30 Sep 2006 16:58:50 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: _acpitool Message-ID: <20060930205850.GA22924@scowler.net> Mail-Followup-To: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) acpitool completion from R.Ramkumar Index: Completion/Linux/Command/_acpitool =================================================================== RCS file: Completion/Linux/Command/_acpitool diff -N Completion/Linux/Command/_acpitool --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Linux/Command/_acpitool 30 Sep 2006 20:57:09 -0000 @@ -0,0 +1,69 @@ +#compdef acpitool + +local ret=1 selbrands disambig +typeset -a brands args + +if ! zstyle -a ":completion:${curcontext}:" acpi-extensions brands || \ + (( $brands[(I)detect] )); then + [[ -d /proc/acpi/toshiba ]] && brands+=toshiba + [[ -d /proc/acpi/asus ]] && brands+=asus + [[ -d /proc/acpi/ibm ]] && brands+=thinkpad +elif (( $brands[(I)all] )); then + brands=(toshiba asus thinkpad) +fi + +args=( + '(-a --ac_adapter)'{-a,--ac_adapter}'[show AC adapter presence]' + '-b[show battery status for available batteries]' + '(-B --battery)'{-B,--battery}'[show detailed battery status for all batteries found]' + '(-c --cpu)'{-c,--cpu}'[show CPU information]' + '(-a --ac_adapter -A -b -B --battery -c --cpu -e -f --fan -t --thermal -w)-e[show just about everything]' + '(-f --fan)'{-f,--fan}'[show fan status]' + '(-h --help)'{-h,--help}'[display help]' + '(-s --suspend)'{-s,--suspend}'[suspend machine to memory (sleep state S3)]' + '-S[suspend machine to disk (sleep state S4)]' + '(-t --thermal)'{-t,--thermal}'[show thermal zone(s) information and trip points]' + '-v[show more verbose output]' + '(-V --version)'{-V,--version}'[output version information and exit]' + '-w[show the wakeup capable devices]' + '-W+[toggle enable/disable wakeup capable device]: :_wakeup_capable_devices' +) + +if (( $brands[(I)asus] )); then + disambig= + (( $brands[(I)(toshiba|thinkpad)] )) && disambig='Asus ' + args+=( + '(-A --Asus)'{-A,--Asus}'[show supported Asus ACPI extensions]' + '-m+[set mail LED status]:mail LED status:((1\:on 0\:off))' + '-n+[set wireless LED status]:wireless LED status:((1\:on 0\:off))' + '-o+[set LCD panel status]:LCD panel status:((1\:on 0\:off))' + "-z+[set ${disambig}LCD brightness level]:${disambig}LCD brightness level:(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)" + ) +fi + +selbrands= +if (( $brands[(I)toshiba] )); then + selbrands=Toshiba + args+=( + '-F+[force fan on or switch back to auto mode]:fan status:((1\:on 0\:auto))' + '(-T --Toshiba)'{-T,--Toshiba}'[show supported Toshiba ACPI extensions]' + ) +fi + +if (( $brands[(I)thinkpad] )); then + [[ -n $selbrands ]] && selbrands+=/ + selbrands=${selbrands}Thinkpad + args+=('-j[eject ultrabay device]') +fi + +if [[ -n $selbrands ]]; then + disambig= + (( $brands[(I)asus] )) && disambig="$selbrands " + args+=( + "-l+[set ${disambig}LCD brightness level]:${disambig}LCD brightness level:(0 1 2 3 4 5 6 7)" + ) +fi + +_arguments -s $args && ret=0 + +return ret Index: Completion/Linux/Type/_wakeup_capable_devices =================================================================== RCS file: Completion/Linux/Type/_wakeup_capable_devices diff -N Completion/Linux/Type/_wakeup_capable_devices --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Linux/Type/_wakeup_capable_devices 30 Sep 2006 20:57:09 -0000 @@ -0,0 +1,15 @@ +#autoload + +local ret=1 item devline expl +typeset -a desc + +_call_program wakeup-capable-devices acpitool -w 2> /dev/null | +while read devline; do + [[ -n ${devline:#(#b)([0-9]#).[[:space:]]#([^[:space:]]#)[[:space:]]#[0-9]#[[:space:]]#(*)} ]] && continue + zformat -f item "${match[1]}:%8d (currently ${match[3]})" d:${match[2]} + desc+=$item +done + +_describe -t wakeup-capable-devices 'wakeup capable device' desc $@ && ret=0 + +return ret