mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
linux-cpupower-4.21-rc1
This cpupower update Linux 4.21 adds support for auto-completion for cpupower tool from Abhishek Goel. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAlwX3PMACgkQCwJExA0N QxzzqQ//Xu0vZeGy7Mk/hU/FR6lnnpvjju79jrlghQ0ZPgFUrmetL3KyleQMa2zZ 7OsVpdRNhE+kkxGStKh81Ts+DwAZaSbw25iGxlF0KOrdq8G7U06cbWI3HKHj+/Ty xKLOY2kInMwBVmYUr6meDqAhci92ZA2cO+owfs2PeR7I6vdMS/jX/ROFxiV9tf/X aczwMlY89qhWp5qrgbzAYtNdDy6jZVptW5teCkmjPUYzr/BANP7/E9F9Z0x9zz2Z 1mEH4Lr+pMIsrAuXH55MYg1foVXmTJiJXL6J4Rs8/xLVcjAedc0H1+mu7hKkRioD sLOCbTWaJlQ26rxOGrOl7h4kxfVpjLlBYnLFjp3rOMV/lIRAfc93qUMHXCyXKf5i 1kkm+pDhUrX1j8lmY9vS9i7UuaJmv8NGvjWEIgiXgP0jVm495HfrcA/DyHrxClul th32DAl4y8HJPDCesXMjzRh9/f+wO5VLqVy4b1cNfv47zGQUEGqdxLhx0OVfrueU FWc5iO5UK5yOue4uOC+VE0IbGGMPIhgJ4i1mwDijBGP5ojBCpCKS8ksXOtyLewOH PzNl/FoNTgMTjXRRDxGhn4at8spfzuelZS9nHNsXnGYb83J6HVYR+SSspChmRmfh Xx01HxEyyCaLfbEbPcZXar3mvGyeCZbLER2Lv42mXvWakoueQ+4= =U+pY -----END PGP SIGNATURE----- Merge tag 'linux-cpupower-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux Pull cpupower utility updates for v4.21 from Shuah Khan: "This cpupower update Linux 4.21 adds support for auto-completion for cpupower tool from Abhishek Goel." * tag 'linux-cpupower-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux: cpupower : Auto-completion for cpupower tool
This commit is contained in:
commit
67e4eb30ea
@ -89,6 +89,7 @@ endif
|
||||
localedir ?= /usr/share/locale
|
||||
docdir ?= /usr/share/doc/packages/cpupower
|
||||
confdir ?= /etc/
|
||||
bash_completion_dir ?= /usr/share/bash-completion/completions
|
||||
|
||||
# Toolchain: what tools do we use, and what options do they need:
|
||||
|
||||
@ -96,7 +97,8 @@ CP = cp -fpR
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROGRAM = ${INSTALL}
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_SCRIPT = ${INSTALL_PROGRAM}
|
||||
#bash completion scripts get sourced and so they should be rw only.
|
||||
INSTALL_SCRIPT = ${INSTALL} -m 644
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting, like "arm-linux-". If you want
|
||||
@ -288,6 +290,8 @@ install-lib:
|
||||
install-tools:
|
||||
$(INSTALL) -d $(DESTDIR)${bindir}
|
||||
$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
|
||||
$(INSTALL) -d $(DESTDIR)${bash_completion_dir}
|
||||
$(INSTALL_SCRIPT) cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower'
|
||||
|
||||
install-man:
|
||||
$(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
|
||||
|
128
tools/power/cpupower/cpupower-completion.sh
Normal file
128
tools/power/cpupower/cpupower-completion.sh
Normal file
@ -0,0 +1,128 @@
|
||||
# -*- shell-script -*-
|
||||
# bash completion script for cpupower
|
||||
# Taken from git.git's completion script.
|
||||
|
||||
_cpupower_commands="frequency-info frequency-set idle-info idle-set set info monitor"
|
||||
|
||||
_frequency_info ()
|
||||
{
|
||||
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"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
frequency-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_frequency_set ()
|
||||
{
|
||||
local flags="-f -g --freq --governor -d --min -u --max -r --related"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
-f| --freq | -d | --min | -u | --max)
|
||||
if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
|
||||
COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_frequencies)' -- "$cur"))
|
||||
fi ;;
|
||||
-g| --governor)
|
||||
if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
|
||||
COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_governors)' -- "$cur"))
|
||||
fi;;
|
||||
frequency-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_idle_info()
|
||||
{
|
||||
local flags="-f --silent"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
idle-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_idle_set()
|
||||
{
|
||||
local flags="-d --disable -e --enable -D --disable-by-latency -E --enable-all"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
idle-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_set()
|
||||
{
|
||||
local flags="--perf-bias, -b"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_monitor()
|
||||
{
|
||||
local flags="-l -m -i -c -v"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev" in
|
||||
monitor) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_taskset()
|
||||
{
|
||||
local prev_to_prev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
case "$prev_to_prev" in
|
||||
-c|--cpu) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "$cur")) ;;
|
||||
esac
|
||||
case "$prev" in
|
||||
frequency-info) _frequency_info ;;
|
||||
frequency-set) _frequency_set ;;
|
||||
idle-info) _idle_info ;;
|
||||
idle-set) _idle_set ;;
|
||||
set) _set ;;
|
||||
monitor) _monitor ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
_cpupower ()
|
||||
{
|
||||
local i
|
||||
local c=1
|
||||
local command
|
||||
|
||||
while test $c -lt $COMP_CWORD; do
|
||||
if test $c == 1; then
|
||||
command="${COMP_WORDS[c]}"
|
||||
fi
|
||||
c=$((++c))
|
||||
done
|
||||
|
||||
# Complete name of subcommand if the user has not finished typing it yet.
|
||||
if test $c -eq $COMP_CWORD -a -z "$command"; then
|
||||
COMPREPLY=($(compgen -W "help -v --version -c --cpu $_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return
|
||||
fi
|
||||
|
||||
# Complete arguments to subcommands.
|
||||
case "$command" in
|
||||
-v|--version) return ;;
|
||||
-c|--cpu) _taskset ;;
|
||||
help) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}")) ;;
|
||||
frequency-info) _frequency_info ;;
|
||||
frequency-set) _frequency_set ;;
|
||||
idle-info) _idle_info ;;
|
||||
idle-set) _idle_set ;;
|
||||
set) _set ;;
|
||||
monitor) _monitor ;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -F _cpupower cpupower 2>/dev/null \
|
||||
|| complete -o default -F _cpupower cpupower
|
Loading…
Reference in New Issue
Block a user