~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/power/cpupower/cpupower-completion.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 # -*- shell-script -*-
  2 # bash completion script for cpupower
  3 # Taken from git.git's completion script.
  4 
  5 _cpupower_commands="frequency-info frequency-set idle-info idle-set set info monitor"
  6 
  7 _frequency_info ()
  8 {
  9         local flags="-f -w -l -d -p -g -a -s -y -o -m -n --freq --hwfreq --hwlimits --driver --policy --governors --related-cpus --affected-cpus --stats --latency --proc --human --no-rounding"
 10         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 11         local cur="${COMP_WORDS[COMP_CWORD]}"
 12         case "$prev" in
 13                 frequency-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 14         esac
 15 }
 16 
 17 _frequency_set ()
 18 {
 19         local flags="-f -g --freq --governor -d --min -u --max -r --related"
 20         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 21         local cur="${COMP_WORDS[COMP_CWORD]}"
 22         case "$prev" in
 23                 -f| --freq | -d | --min | -u | --max)
 24                 if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
 25                         COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_frequencies)' -- "$cur"))
 26                 fi ;;
 27                 -g| --governor)
 28                 if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
 29                         COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_governors)' -- "$cur"))
 30                 fi;;
 31                 frequency-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 32         esac
 33 }
 34 
 35 _idle_info()
 36 {
 37         local flags="-f --silent"
 38         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 39         local cur="${COMP_WORDS[COMP_CWORD]}"
 40         case "$prev" in
 41                 idle-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 42         esac
 43 }
 44 
 45 _idle_set()
 46 {
 47         local flags="-d --disable -e --enable -D --disable-by-latency -E --enable-all"
 48         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 49         local cur="${COMP_WORDS[COMP_CWORD]}"
 50         case "$prev" in
 51                 idle-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 52         esac
 53 }
 54 
 55 _set()
 56 {
 57         local flags="--perf-bias, -b"
 58         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 59         local cur="${COMP_WORDS[COMP_CWORD]}"
 60         case "$prev" in
 61                 set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 62         esac
 63 }
 64 
 65 _monitor()
 66 {
 67         local flags="-l -m -i -c -v"
 68         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 69         local cur="${COMP_WORDS[COMP_CWORD]}"
 70         case "$prev" in
 71                 monitor) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
 72         esac
 73 }
 74 
 75 _taskset()
 76 {
 77         local prev_to_prev="${COMP_WORDS[COMP_CWORD-2]}"
 78         local prev="${COMP_WORDS[COMP_CWORD-1]}"
 79         local cur="${COMP_WORDS[COMP_CWORD]}"
 80         case "$prev_to_prev" in
 81                 -c|--cpu) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "$cur")) ;;
 82         esac
 83         case "$prev" in
 84                 frequency-info) _frequency_info ;;
 85                 frequency-set) _frequency_set ;;
 86                 idle-info) _idle_info ;;
 87                 idle-set) _idle_set ;;
 88                 set) _set ;;
 89                 monitor) _monitor ;;
 90         esac
 91 
 92 }
 93 
 94 _cpupower ()
 95 {
 96         local i
 97         local c=1
 98         local command
 99 
100         while test $c -lt $COMP_CWORD; do
101                 if test $c == 1; then
102                         command="${COMP_WORDS[c]}"
103                 fi
104                 c=$((++c))
105         done
106 
107         # Complete name of subcommand if the user has not finished typing it yet.
108         if test $c -eq $COMP_CWORD -a -z "$command"; then
109                 COMPREPLY=($(compgen -W "help -v --version -c --cpu $_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}"))
110                 return
111         fi
112 
113         # Complete arguments to subcommands.
114         case "$command" in
115                 -v|--version) return ;;
116                 -c|--cpu) _taskset ;;
117                 help) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}")) ;;
118                 frequency-info) _frequency_info ;;
119                 frequency-set) _frequency_set ;;
120                 idle-info) _idle_info ;;
121                 idle-set) _idle_set ;;
122                 set) _set ;;
123                 monitor) _monitor ;;
124         esac
125 }
126 
127 complete -o bashdefault -o default -F _cpupower cpupower 2>/dev/null \
128     || complete -o default -F _cpupower cpupower

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php