Package: bash-completion
Version: 20080617.4
Severity: minor
Tags: patch

Hi,
this patch adds some support for xrand completion.

Anton

-- System Information:
Debian Release: sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-nb.a (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bash-completion depends on:
ii  bash                          3.2-4      The GNU Bourne Again SHell
ii  ucf                           3.007      Update Configuration File: preserv

bash-completion recommends no packages.

-- no debconf information
--- bash-completion-20080617.4/bash_completion	2008-06-23 19:25:14.000000000 +0200
+++ /etc/bash_completion	2008-06-24 12:26:30.000000000 +0200
@@ -5698,6 +5698,56 @@
 } &&
 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
+
+
+
 # mplayer(1) completion
 #
 have mplayer && {

Reply via email to