63 lines
2.1 KiB
Plaintext
Raw Normal View History

# bash completion for xrandr -*- shell-script -*-
2009-05-27 18:39:19 +02:00
_xrandr()
{
local cur prev words cword
_init_completion || return
case "$prev" in
-display|-d|-help|-s|--size|-r|--rate|--refresh|--screen|--fb|--fbmm|\
--dpi|--pos|--set|--scale|--transform|--crtc|--panning|--gamma|\
--newmode|--rmmode|--addmode|--delmode)
return
;;
2011-09-30 22:17:48 +04:00
--output|--left-of|--right-of|--above|--below|--same-as)
local outputs=$( "$1" | awk '/connected/ {print $1}' )
COMPREPLY=( $( compgen -W "$outputs" -- "$cur" ) )
return
2009-10-04 19:42:50 +02:00
;;
--mode)
2013-02-02 19:40:46 +02:00
local i output
for (( i=1; i < cword; i++ )); do
if [[ "${words[i]}" == --output ]]; then
output=${words[i+1]}
2009-10-04 19:42:50 +02:00
break
fi
done
if [[ $output ]]; then
local modes=$( "$1" | sed -e "1,/$output/ d" \
2013-02-02 19:49:19 +02:00
-e "/connected/,$ d" \
-e "s/\([^[:space:]]\)[[:space:]].*/\1/" )
COMPREPLY=( $( compgen -W "$modes" -- "$cur" ) )
fi
return
2009-10-04 19:42:50 +02:00
;;
2011-09-30 22:17:48 +04:00
-o|--orientation)
COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \
"$cur" ) )
return
2011-09-30 22:17:48 +04:00
;;
--reflect)
COMPREPLY=( $( compgen -W 'normal x y xy' -- "$cur" ) )
return
2011-09-30 22:17:48 +04:00
;;
--rotate)
COMPREPLY=( $( compgen -W 'normal inverted left right' -- "$cur" ) )
return
2011-09-30 22:17:48 +04:00
;;
--setprovideroutputsource|--setprovideroffloadsink)
local providers=$( "$1" --listproviders 2>/dev/null |
sed -ne 's/.* name:\([^ ]*\).*/\1/p' )
COMPREPLY=( $( compgen -W "$providers" -- "$cur" ) )
# TODO 2nd arg needed, is that a provider as well?
return
;;
2009-10-04 19:42:50 +02:00
esac
2009-05-27 18:39:19 +02:00
2013-02-02 20:01:33 +02:00
COMPREPLY=( $( compgen -W '$( "$1" -help 2>&1 |
sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help - )' -- "$cur" ) )
2009-05-27 18:39:19 +02:00
} &&
complete -F _xrandr xrandr
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh