2011-11-01 22:14:45 +02:00
|
|
|
# bash completion for xrandr -*- shell-script -*-
|
2009-05-27 18:39:19 +02:00
|
|
|
|
|
|
|
_xrandr()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
|
|
|
|
2011-11-20 17:00:03 +03:00
|
|
|
case "$prev" in
|
2013-02-02 20:08:57 +02:00
|
|
|
-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)
|
2011-11-20 23:42:20 +03:00
|
|
|
local outputs=$( xrandr | awk '/connected/ {print $1}' )
|
|
|
|
COMPREPLY=( $( compgen -W "$outputs" -- "$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
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
|
2011-11-20 17:00:03 +03:00
|
|
|
if [[ "${words[i]}" == --output ]]; then
|
2011-04-21 11:04:51 +03:00
|
|
|
output=${words[i+1]}
|
2009-10-04 19:42:50 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2013-02-02 19:42:24 +02:00
|
|
|
if [[ $output ]]; then
|
|
|
|
local modes=$( xrandr | sed -e "1,/$output/ d" \
|
2013-02-02 19:49:19 +02:00
|
|
|
-e "/connected/,$ d" \
|
|
|
|
-e "s/\([^[:space:]]\)[[:space:]].*/\1/" )
|
2013-02-02 19:42:24 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$modes" -- "$cur" ) )
|
|
|
|
fi
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2009-10-04 19:42:50 +02:00
|
|
|
;;
|
2011-09-30 22:17:48 +04:00
|
|
|
-o|--orientation)
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \
|
|
|
|
"$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-09-30 22:17:48 +04:00
|
|
|
;;
|
|
|
|
--reflect)
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'normal x y xy' -- "$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-09-30 22:17:48 +04:00
|
|
|
;;
|
|
|
|
--rotate)
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'normal inverted left right' -- "$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-09-30 22:17:48 +04:00
|
|
|
;;
|
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-01 20:54:51 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|