split xrandr completion

This commit is contained in:
Guillaume Rousse 2009-05-27 18:39:19 +02:00
parent 313867cada
commit c2b44b5fe5
3 changed files with 52 additions and 48 deletions

View File

@ -98,6 +98,7 @@ bashcomp_DATA = contrib/ant \
contrib/xhost \
contrib/xm \
contrib/xmllint \
contrib/xrandr \
contrib/yum
EXTRA_DIST = $(sysconf_DATA) $(bashcomp_DATA) to_review

View File

@ -4396,54 +4396,6 @@ _ypmatch()
} &&
complete -F _ypmatch ypmatch ypcat
#xrandr(1) completion
#
have xrandr &&
_xrandr()
{
local cur prev output modes
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
--output)
local outputs=$(xrandr|grep 'connected'|awk '{print $1}')
COMPREPLY=( $(compgen -W "$outputs" -- $cur))
return 0
;;
--mode)
for(( i = 1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == "--output" ]]; then
output=${COMP_WORDS[i+1]}
break
fi
done
modes=$(xrandr|sed -e "1,/$output/ d" \
-e "/connected/,$ d"|awk '{print $1}')
COMPREPLY=( $( compgen -W "$modes" -- $cur))
return 0
;;
esac
case "$cur" in
*)
COMPREPLY=( $(compgen -W '-d -display -help -o \
--orientation -q --query -s --size\
-r --rate -v --version -x -y --screen \
--verbose --dryrun --prop --fb --fbmm --dpi \
--output --auto --mode --preferred --pos \
--reflect --rotate --left-of --right-of \
--above --below --same-as --set --off --crtc \
--newmode --rmmode --addmode --delmode' -- $cur))
return 0
;;
esac
return 0
} &&
complete -F _xrandr xrandr
# iconv(1) completion
#
have iconv &&

51
contrib/xrandr Normal file
View File

@ -0,0 +1,51 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for xrandr
have xrandr &&
_xrandr()
{
local cur prev output modes
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
--output)
local outputs=$(xrandr|grep 'connected'|awk '{print $1}')
COMPREPLY=( $(compgen -W "$outputs" -- $cur))
return 0
;;
--mode)
for(( i = 1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == "--output" ]]; then
output=${COMP_WORDS[i+1]}
break
fi
done
modes=$(xrandr|sed -e "1,/$output/ d" \
-e "/connected/,$ d"|awk '{print $1}')
COMPREPLY=( $( compgen -W "$modes" -- $cur))
return 0
;;
esac
case "$cur" in
*)
COMPREPLY=( $(compgen -W '-d -display -help -o \
--orientation -q --query -s --size\
-r --rate -v --version -x -y --screen \
--verbose --dryrun --prop --fb \
--fbmm --dpi --output --auto --mode \
--preferred --pos --reflect --rotate \
--left-of --right-of --above --below \
--same-as --set --off --crtc --newmode \
--rmmode --addmode --delmode' -- $cur))
return 0
;;
esac
return 0
} &&
complete -F _xrandr xrandr