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
|
|
|
|
|
|
|
|
local output modes
|
2009-05-27 18:39:19 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2011-09-30 22:17:48 +04:00
|
|
|
--output|--left-of|--right-of|--above|--below|--same-as)
|
2009-12-21 23:00:31 +02:00
|
|
|
local outputs=$(xrandr|awk '/connected/ {print $1}')
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $(compgen -W "$outputs" -- "$cur"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--mode)
|
2011-04-21 11:04:51 +03:00
|
|
|
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
|
|
|
|
modes=$(xrandr|sed -e "1,/$output/ d" \
|
|
|
|
-e "/connected/,$ d"|awk '{print $1}')
|
|
|
|
COMPREPLY=( $( compgen -W "$modes" -- "$cur"))
|
|
|
|
return 0
|
|
|
|
;;
|
2011-09-30 22:17:48 +04:00
|
|
|
-o|--orientation)
|
|
|
|
COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \
|
|
|
|
"$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--reflect)
|
|
|
|
COMPREPLY=( $( compgen -W 'normal x y xy' -- \
|
|
|
|
"$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--rotate)
|
|
|
|
COMPREPLY=( $( compgen -W 'normal inverted left right' -- \
|
|
|
|
"$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-10-04 19:42:50 +02:00
|
|
|
esac
|
2009-05-27 18:39:19 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $cur in
|
2009-10-04 19:42:50 +02:00
|
|
|
*)
|
2009-10-18 22:12:37 +03:00
|
|
|
COMPREPLY=( $(compgen -W '-display -help --orientation --query \
|
|
|
|
--size --rate --version -x -y --screen --verbose --dryrun \
|
2011-09-30 22:17:48 +04:00
|
|
|
--q1 --q12 --nograb --prop --properties --fb --fbmm --dpi \
|
|
|
|
--output --auto --mode --preferred --pos --rate --refresh \
|
|
|
|
--reflect --rotate --left-of --right-of --above --below \
|
|
|
|
--same-as --set --scale --transform --off --crtc --panning \
|
|
|
|
--gamma --brightness --primary --noprimary --newmode --rmmode \
|
|
|
|
--addmode --delmode' -- "$cur") )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
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
|