[Bash-completion-devel] Completion for audtool.

gotf genius-of-the-fall at yandex.ru
Mon Feb 1 13:03:50 UTC 2010


Hi. Here is completion for audtool (Audacious audio player remote 
control utility) version 1.5. Please review it.

------

_audtool() {
    local cur prev opts pl pq
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="current-song current-song-filename current-song-length
    current-song-length-seconds current-song-length-frames
    current-song-output-length current-song-output-length-seconds
    current-song-output-length-frames current-song-bitrate
    current-song-bitrate-kbps current-song-frequency 
current-song-frequency-khz
    current-song-channels current-song-tuple-data current-song-info
    playlist-advance playlist-reverse playlist-addurl playlist-insurl
    playlist-addurl-to-new-playlist playlist-delete playlist-length
    playlist-song playlist-song-filename playlist-song-length
    playlist-song-length-seconds playlist-song-length-frames 
playlist-display
    playlist-position playlist-jump playlist-clear playlist-repeat-status
    playlist-repeat-toggle playlist-shuffle-status playlist-shuffle-toggle
    playlist-tuple-data playqueue-add playqueue-remove playqueue-is-queued
    playqueue-get-queue-position playqueue-get-list-position 
playqueue-length
    playqueue-display playqueue-clear playback-play playback-pause
    playback-playpause playback-stop playback-playing playback-paused
    playback-stopped playback-status playback-seek playback-seek-relative
    get-volume set-volume equalizer-activate equalizer-get equalizer-set
    equalizer-get-preamp equalizer-set-preamp equalizer-get-band
    equalizer-set-band mainwin-show playlist-show equalizer-show
    filebrowser-show jumptofile-show preferences-show about-show activate
    always-on-top get-skin set-skin version shutdown list-handlers help"
    td="artist album title track_number year date genre comment file_name
    file_ext file_path length formatter custom mtime"
    pl=$(seq -s ' ' $(audtool playlist-length))
    pq=$(seq -s ' ' $(audtool playqueue-length))

    if [[ ${COMP_CWORD} -eq 1 ]]; then    
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
    case ${prev} in
        playlist-addurl|playlist-addurl-to-new-playlist|playlist-insurl|\
        set-skin)
            _filedir
        ;;
        playlist-delete|playlist-song|playlist-song-filename|\
        playlist-song-length|playlist-song-length-seconds|\
        playlist-song-length-frames|playqueue-add|playqueue-remove|\
        playqueue-get-queue-position|playlist-jump)
            COMPREPLY=( $(compgen -W "${pl}" -- ${cur}) )
        ;;
        playqueue-get-list-position)
            COMPREPLY=( $(compgen -W "${pq}" -- ${cur}) )
        ;;
        current-song-tuple-data|playlist-tuple-data)
            COMPREPLY=( $(compgen -W "${td}" -- ${cur}) )
        ;;
        *)
            COMPREPLY=()
        ;;
    esac
}
complete -o filenames -F _audtool audtool

------

Hope it will be useful. With best regards, GotF.



More information about the Bash-completion-devel mailing list