File: _draai

package info (click to toggle)
draai 20180521-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 652 kB
  • sloc: sh: 853; perl: 170; makefile: 28
file content (133 lines) | stat: -rw-r--r-- 6,979 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#compdef draai

# This file is maintained at http://git.mdcc.cx/draai
# Heavily based upon /usr/share/zsh-beta/4.3.2-dev-1/functions/Completion/Unix/_mpc
# See Chapter 6: Completion in "A User's Guide to the Z-Shell" by Peter Stephenson
# at http://zsh.dotsrc.org/Guide/zshguide06.html#l144

# Copyright: © 1992-2000 Paul Falstad, Richard Coleman, Zoltán Hidvégi,
#  Andrew Main, Peter Stephenson, Sven Wischnowsky, and others.
#
# Permission is hereby granted, without written agreement and without
# licence or royalty fees, to use, copy, modify, and distribute this
# software and to distribute modified versions of this software for any
# purpose, provided that the above copyright notice and the following
# two paragraphs appear in all copies of this software.
# .
# In no event shall the Zsh Development Group be liable to any party for
# direct, indirect, special, incidental, or consequential damages arising out
# of the use of this software and its documentation, even if and the Zsh
# Development Group have been advised of the possibility of such damage.
# .
# The Zsh Development Group specifically disclaim any warranties, including,
# but not limited to, the implied warranties of merchantability and fitness
# for a particular purpose.  The software provided hereunder is on an "as is"
# basis, and the Zsh Development Group have no obligation to provide
# maintenance, support, updates, enhancements, or modifications.


# To be used by zsh when completing from draai<tab>

_draai_command() {
  local draai_cmds

  draai_cmds=(
    add:"Add file(s) (given either as args or on stdin) to playlist.  You probably want to have 'draai add' read from a pipe fed by e.g. 'draai listall' or 'draai search'. "
    crescendo:"Play louder. "
    delete:"Delete track(s) from current playlist. Last arguments should be _positions_ of tracks to be removed, not filename.  If no position is given, deletes upcoming track from playlist. "
    diminuendo:"Play softer. "
    draai:"Play music: the files given as args and playlists passed via --playlist. "
    fastforward:"Seek forward in current track. "
    guestlist:"Reschedule listed tracknumbers as upcoming tracks. Last arguments should be the positions of tracks to be put on the guestlist, not filenames. "
    harder:"Play louder. "
    init:"Start a bunch of X terminals setting up some draai jobs: tail, logtail, watch, syslog, ... "
    insert:"Add file(s) (given either as args or on stdin) to playlist and schedule it as upcoming track.  You probably want to have 'draai insert' read from a pipe fed by 'draai search'. "
    list:"List current playlist. "
    listall:"List all files as served by music database. "
    logtail:"Run tail(1) on system log file. "
    move:"Move tracknumber to tracknumber given as last argument. "
    osjittisstil:"Run this if unwanted silence pops up during a playing session (for now, it runs draai --sloppy skip). "
    peek:"Show status of current song, and show upcoming $peek FIXME tracks. "
    play:"Play music. "
    quit:"quit "
    search:"Search for substrings in all song tag types (artist, title, comment, filename, ...).  Similar to 'mpc search any <query>'.  You'll typically want to pipe this commands output to e.g. 'draai insert'. "
    shuffle:"Shuffle the playlist.  By default, this task is delegated to dr_unsort(1). However, if draai runs in "sloppy" or in "native shuffle" mode, then mpc native shuffling is done (by calling "mpc shuffle").  Draai runs in "sloppy" mode when the DR_SLOPPY environment variable is set, or when the --sloppy option is passed.  Draai runs in "native shuffle" mode when the DR_SHUFFLE_NATIVE environment variable is set. "
    skip:"Skip this track, start playing the next one now. "
    syslog:"Send raw information from tail to syslog.  You likely want to run "draai syslog" in the background. "
    tail:"Print information about track when it starts playing, similar to tail -f on a logfile. "
    unguestlist:"Reschedule listed tracknumbers to end of playlist. "
    watch:"Run watch(1) on "draai peek". "
    zachter:"Play softer. "
    zap:"Move tracknumber to position one and immediately start playing it.  Typically used to deal with radiostations in playlist. "
)

#   draai:"play music (now or later)"
#   init:"start a bunch of x terminals setting up some draai jobs"
#   list:"list current playlist"
#   guestlist:"reschedule listed tracknumbers as upcoming tracks"
#   unguestlist:"reschedule listed tracknumbers to end of playlist"
#   delete:"delete track(s) from current playlist"
#   fastforward:"seek forward in current track"
#   skip:"skip this track, start playing the next one now"
#   osjittisstil:"run this if unwanted silence pops up during a playing session"
#   resume:"start playing: abort pause"
#   unpause:"start playing: abort pause"
#   pause:"pause playing"
#   quit:"quit (now or later)"
#   tail:"print information about track when it starts playing, similar to tail -f on a logfile (see init)"
#   logtail:"run tail on syslog (see init)"
#   peek:"show status of current song, and upcoming tracks (see init)"
#   syslog:"sent raw information from tail to syslog (see init)"
# )

  if (( CURRENT == 1 )); then
    _describe -t command "draai commands" draai_cmds
  else
    local curcontext="$curcontext"
  fi

  local cmd=$words[1]

  local curcontext="${curcontext%:*}:draai-${cmd}"
  _call_function ret _draai_$cmd
}


# based upon _mpc_helper_files
_draai_draai() {
  local -U list expl
  if [[ $words[CURRENT] != */* ]]; then
    list=( ${${(f)"$(mpc listall)"}%%/*})
    _wanted files expl file compadd -qS/ -a list
  else
    list=(${(f)"$(mpc tab $words[CURRENT])"})
    _wanted files expl file _multi_parts / list
  fi
}

# based upon _mpc_helper_playlists
_draai_playlist() {
  local list expl
  list=($(mpc lsplaylists))
  _wanted list expl playlist compadd $expl -a list
}

_arguments \
  '--debug[Be very verbose. ]' \
  '--noshuffle[Do not shuffle tracks and leave random mode untouched (default is: do shuffle and disable random mode).  See also the script dr_unsort. ]' \
  '--playlist[Playlist file; option can be supplied more than once.  To be used with command "draai". ]' \
  '--raw[Print raw stuff, suitable for postprocessing (if combined with tail, peek or list). ]' \
  '--sloppy[Do not try hard to make everything sound smooth.  If combined with skip: risk a squeak on old hardware. ]' \
  '--time[If combined with commands quit or draai: time at which to quit or start. ]' \
   '*::draai command:_draai_command'

#  '--version[show program version number and exit]' \
#  '--help[show help message and exit]' \
#  '--debug[be very verbose]' \
#  '--noshuffle[do not shuffle tracks]' \
#  '--playlist[playlist file]:playlist:_draai_playlist' \
#  '--time[if combined with quit or draai: time at which to quit or start]:time' \
#  '--raw[if combined with tail: print raw stuff]' \
#  '--license[show license and exit]' \
#  '*::draai command:_draai_command'