Package: mplayer
Version: 1.0~rc1-12etch1
Severity: wishlist
Tags: patch

Please, can you include this bash_completion script in mplayer package?

It provides bash expansion logic for mplayer mencoder gmplayer and kplayer.

I think it doesn't harm if you provide it once for each of these packages,
since the _mplayer() function is replaced in memory and doesn't take extra
space.

It's based on the mplayer blurb of /etc/bash_completion.  However, that
script has been unmaintained for a long time (both in upstream and in debian),
so I think it's a good idea to start moving things to their respective
packages.

The version I'm attaching includes detection for flac and mka files that was
submitted to upstream years ago, with no response.

-- System Information:
Debian Release: lenny/sid
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-amd64
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
#
#   Copyright (C) Ian Macdonald <[EMAIL PROTECTED]>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2, or (at your option)
#   any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# mplayer(1) completion
#
have mplayer && {
_mplayer_options_list()
{
        cur=${cur%\\}
        COMPREPLY=( $( $1 $2 help 2> /dev/null | \
                sed -e '1,/^Available/d' | awk '{print $1}' | \
                sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \
                grep "^$cur" ) )
}

_mplayer()
{
        local cmd cur prev skinsdir IFS=$' \t\n' i j k=0

        COMPREPLY=()
        cmd=${COMP_WORDS[0]}
        cur=${COMP_WORDS[COMP_CWORD]}
        prev=${COMP_WORDS[COMP_CWORD-1]}

        case "$prev" in
                -@(ac|afm|vc|vfm|ao|vo|vop|fstype))
                        _mplayer_options_list mplayer $prev
                        return 0
                        ;;
                -@(oac|ovc|of))
                        _mplayer_options_list mencoder $prev
                        return 0
                        ;;
                -audiofile)
                        _filedir 
'@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)'
                        return 0
                        ;;
                -font)
                        _filedir '@(desc|ttf)'
                        return 0
                        ;;
                -sub)
                        _filedir 
'@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js)'
                        return 0
                        ;;
                -vobsub)
                        _filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
                        IFS=$'\t\n' 
                        COMPREPLY=( $( for i in [EMAIL PROTECTED]; do
                                                if [ -f $i -a -r $i ]; then
                                                        echo ${i%.*}
                                                else
                                                        echo $i
                                                fi
                                       done ) )
                        IFS=$' \t\n' 
                        return 0
                        ;;
                -ifo)
                        _filedir '@(ifo|IFO)'
                        return 0
                        ;;
                -cuefile)
                        _filedir '@(bin|BIN|cue|CUE)'
                        return 0
                        ;;
                -skin)
                        # if you don't have installed mplayer in /usr/local you
                        # may want to set the MPLAYER_SKINS_DIR global variable
                        if [ -n "$MPLAYER_SKINS_DIR" ]; then
                                skinsdir=$MPLAYER_SKINS_DIR
                        else
                                skinsdir=/usr/local/share/mplayer/Skin
                        fi

                        IFS=$'\t\n' 
                        for i in ~/.mplayer/Skin $skinsdir; do
                                if [ -d $i -a -r $i ]; then
                                        for j in $( compgen -d $i/$cur ); do
                                                COMPREPLY[$k]=${j#$i/}
                                                k=$((++k))
                                        done
                                fi
                        done
                        IFS=$' \t\n' 
                        return 0
                        ;;
                -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
                        cur=${cur:=/dev/}
                        _filedir
                        return 0
                        ;;
                -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
                -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
                -passlogfile)
                        _filedir
                        return 0
                        ;;
                -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \
                -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \
                -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \
                -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \
                -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \
                -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \
                -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
                -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \
                -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \
                -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \
                -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \
                -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \
                
-sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
                        return 0
                        ;;
                -lavdopts)
                        COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \
                                        -- $cur ) )
                        return 0
                        ;;
                -lavcopts)
                        COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= \
                                        vqmax= mbqmin= mbqmax= vqdiff= \
                                        vmax_b_frames= vme= vhq v4mv \
                                        keyint= vb_strategy= vpass= \
                                        aspect= vbitrate= vratetol= \
                                        vrc_maxrate= vrc_minrate= \
                                        vrc_buf_size= vb_qfactor= vi_qfactor= \
                                        vb_qoffset= vi_qoffset= vqblur= \
                                        vqcomp= vrc_eq= vrc_override= \
                                        vrc_init_cplx= vqsquish= vlelim= \
                                        vcelim= vstrict= vdpart vpsize= gray \
                                        vfdct= idct= lumi_mask= dark_mask= \
                                        tcplx_mask= scplx_mask= naq ildct \
                                        format= pred qpel precmp= cmp= \
                                        subcmp= predia= dia= trell last_pred= \
                                        preme= subq= psnr mpeg_quant aic umv' \
                                        -- $cur ) )
                        return 0
                        ;;
                -ssf)
                        COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \
                                        cvs=' -- $cur ) )
                        return 0
                        ;;
                -jpeg)
                        COMPREPLY=( $( compgen -W 'noprogressive progressive \
                                        nobaseline baseline optimize= \
                                        smooth= quality= outdir=' -- $cur ) )
                        return 0
                        ;;
                -xvidopts)
                        COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) )
                        return 0
                        ;;
                -xvidencopts)
                        COMPREPLY=( $( compgen -W 'pass= bitrate= \
                                        fixed_quant= me_quality= 4mv \
                                        rc_reaction_delay_factor= \
                                        rc_averaging_period= rc_buffer= \
                                        quant_range= min_key_interval= \
                                        max_key_interval= mpeg_quant \
                                        mod_quant lumi_mask hintedme \
                                        hintfile debug keyframe_boost= \
                                        kfthreshold= kfreduction=' -- $cur ) )
                        return 0
                        ;;
                -divx4opts)
                        COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \
                                        min_quant= max_quant= rc_period= \
                                        rc_reaction_period= crispness= \
                                        rc_reaction_ratio= pass= vbrpass= \
                                        help' -- $cur ) )
                        return 0
                        ;;
                -info)
                        COMPREPLY=( $( compgen -W 'name= artist= genre= \
                                        subject= copyright= srcform= \
                                        comment= help' -- $cur ) )
                        return 0
                        ;;
                -lameopts)
                        COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \
                                        ratio= vol= mode= padding= fast \
                                        preset= help' -- $cur ) )
                        return 0
                        ;;
                -rawaudio)
                        COMPREPLY=( $( compgen -W 'on channels= rate= \
                                        samplesize= format=' -- $cur ) )
                        return 0
                        ;;
                -rawvideo)
                        COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \
                                        4cif pal ntsc w= h= y420 yv12 yuy2 \
                                        y8 format= size=' -- $cur ) )
                        return 0
                        ;;
                -aop)
                        COMPREPLY=( $( compgen -W 'list= delay= format= fout= \
                                        volume= mul= softclip' -- $cur ) )
                        return 0
                        ;;
                -dxr2)
                        COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \
                                        iec958-decoded mute ucode= 75ire bw \
                                        color interlaced macrovision= norm= \
                                        square-pixel ccir601-pixel cr-left= \
                                        cr-right= cr-top= cr-bot= ck-rmin= \
                                        ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
                                        ck-bmax= ck-r= ck-g= ck-b= \
                                        ignore-cache= ol-osd= olh-cor= \
                                        olw-cor= olx-cor= oly-cor= overlay \
                                        overlay-ratio= update-cache' -- $cur ))
                        return 0
                        ;;
                -tv)
                        COMPREPLY=( $( compgen -W 'on noaudio driver= device= \
                                        input= freq= outfmt= width= height= \
                                        buffersize= norm= channel= chanlist= \
                                        audiorate= forceaudio alsa amode= \
                                        forcechan= adevice= audioid= volume= \
                                        bass= treble= balance= fps= \
                                        channels= immediatemode=' -- $cur ) )
                        return 0
                        ;;
                -mf)
                        COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \
                                        -- $cur ) )
                        return 0
                        ;;
                -cdda)
                        COMPREPLY=( $( compgen -W 'speed= paranoia= \
                                        generic-dev= sector-size= overlap= \
                                        toc-bias toc-offset= skip noskip' \
                                        -- $cur ) )
                        return 0
                        ;;
                -input)
                        COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \
                                        keylist cmdlist js-dev file' -- $cur ) )
                        return 0
                        ;;
                -af)
                        COMPREPLY=( $( compgen -W 'resample resample= \
                                        channels channels= format format= \
                                        volume volume= delay delay= pan \
                                        pan= sub sub= surround surround=' \
                                        -- $cur ) )
                        return 0
                        ;;
                -af-adv)
                        COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) )
                        return 0
                        ;;
        esac

        case "$cur" in
                -*)
                        COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \
                                        -audiofile -cdrom-device -cache -cdda \
                                        -channels -chapter -csslib -demuxer \
                                        -dvd -dvd-device -dvdangle -dvdauth \
                                        -dvdkey -dvdnav -forceidx -fps -frames \
                                        -hr-mp3-seek -idx -mc -mf -ni -nobps \
                                        -passwd -rawaudio -rtsp-stream-over-tcp\
                                        -skipopening -sb -srate -ss -tv -user \
                                        -vcd -vid -vivo -ifo -ffactor -font \
                                        -noautosub -nooverlapsub -sid -slang \
                                        -sub -subcc -subcp -sub-demuxer \
                                        -subdelay -subfont-autoscale \
                                        -subfont-blur -subfont-encoding \
                                        -subfont-osd-scale -subfont-outline \
                                        -subfont-text-scale -subfps -subfile \
                                        -subpos -unicode -utf8 -vobsub \
                                        -vobsubid -ac -afm -aspect -flip \
                                        -lavdopts -noaspect -nosound -pp -ssf \
                                        -stereo -sws -vc -vfm -vop -xvidopts\
                                        -xy -zoom -bandwidth -cuefile \
                                        -noextbased -rawvideo -overlapsub \
                                        -sub-bg-alpha -sub-bg-color -subalign \
                                        -subwidth -sub-no-text-pp -spualign \
                                        -spuaa -spugauss -pphelp -verbose -v \
                                        -noni -noidx -nohr-mp3-seek -extbased \
                                        -bps -oldpp -nozoom -noflip -nounicode \
                                        -noutf8' -- $cur ) )
                        # add mplayer specific options
                        [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( [EMAIL 
PROTECTED] \
                                $(compgen -W '-autoq -autosync -benchmark \
                                        -framedrop -h -help -hardframedrop \
                                        -identify -input -lircconf -loop \
                                        -nojoystick -nolirc -nortc -playlist \
                                        -quiet -really-quiet -rnd -sdp -skin \
                                        -slave -softsleep -speed -sstep \
                                        -use-stdin -dumpaudio -dumpfile \
                                        -dumpstream -dumpvideo -dumpmicrodvdsub\
                                        -dumpmpsub -dumpsrtsub -dumpjacosub \
                                        -dumpsami -dumpsub -osdlevel -af \
                                        -af-adv -ao -aofile -aop -delay -mixer \
                                        -nowaveheader -bpp -brightness \
                                        -contrast -display -double -dr -dxr2 \
                                        -fb -fbmode -fbmodeconfig -forcexv -fs \
                                        -geometry -hue -icelayer -jpeg \
                                        -monitor-dotclock -monitor-hfreq \
                                        -monitor-vfreq -monitoraspect \
                                        -nograbpointer -noslices -panscan \
                                        -rootwin -saturation -screenw -screenh \
                                        -stop-xscreensaver -vm -vo -vsync -wid \
                                        -xineramascreen -z -zrbw -zrcrop \
                                        -zrdev -zrfd -zrhelp -zrnorm -zrquality 
\
                                        -zrvdec -zrhdec -zrxdoff -zrydoff -y \
                                        -edl -edlout -enqueue -fixed-vo \
                                        -menu -menu-root -menu-cfg -shuffle \
                                        -format -aahelp -dfbopts -fstype \
                                        -guiwid -nokeepaspect -x --help \
                                        -aaosdcolor -aasubcolor -aadriver \
                                        -aaextended -aaeight' -- $cur) )
                        # add mencoder specific options
                        [[ "$cmd" = mencoder ]] && COMPREPLY=( [EMAIL 
PROTECTED] \
                                $(compgen -W '-audio-density -audio-delay \
                                        -audio-preload -divx4opts -endpos \
                                        -ffourcc -include -info -lameopts \
                                        -lavcopts -noskip -o -oac -ofps -ovc \
                                        -passlogfile -skiplimit -vobsubout \
                                        -vobsuboutindex -vobsuboutid \
                                        -xvidencopts -of --verbose' -- $cur) )
                        ;;
                *)
                        _filedir 
'@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV)'
                        ;;
        esac

        return 0
}
complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
}

Reply via email to