zsh-workers
 help / color / Atom feed
* Completion for aplay from alsa-utils
@ 2019-11-02 21:13 Sebastian Gniazdowski
  2019-11-03 23:17 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-02 21:13 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1.1: Type: text/plain, Size: 388 bytes --]

Hello,
the submitted completion is in file _alsa-utils and covers:
- all options of the aplay command, with the =-type options correctly
recognized,
- exclusion lists for the options,
- _file completion for *:… arguments.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #1.2: Type: text/html, Size: 761 bytes --]

<div dir="ltr"><div>Hello,</div><div>the submitted completion is in file _alsa-utils and covers:</div><div>- all options of the aplay command, with the =-type options correctly recognized,</div><div>- exclusion lists for the options,</div><div>- _file completion for *:… arguments.</div><div></div><div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Sebastian Gniazdowski<br>News: <a href="https://twitter.com/ZdharmaI" target="_blank">https://twitter.com/ZdharmaI</a><br>IRC: <a href="https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin" target="_blank">https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin</a><br>Blog: <a href="http://zdharma.org" target="_blank">http://zdharma.org</a></div></div></div>

[-- Attachment #2: 0001-Completion-for-aplay-from-alsa-utils.patch.txt --]
[-- Type: text/plain, Size: 2986 bytes --]

From 087505538427f58bac1cc8bde90e95614063f206 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 29 Oct 2019 18:59:46 +0100
Subject: [PATCH] Completion for aplay from alsa-utils

---
 Completion/Linux/Command/_alsa-utils | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Linux/Command/_alsa-utils

diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils
new file mode 100644
index 000000000..e8356b95a
--- /dev/null
+++ b/Completion/Linux/Command/_alsa-utils
@@ -0,0 +1,54 @@
+#compdef aplay
+# Copyright (c) 2019 Sebastian Gniazdowski
+
+setopt localoptions warncreateglobal typesetsilent
+
+local -a opts
+opts=(
+  + '(operation)'
+  {-h,--help}'[print help message]'
+  --version'[print current version]'
+  {-l,--list-devices}'[list all soundcards and digital audio devices]'
+  {-L,--list-pcms}'[list device names]'
+  + option
+  {-D,--device}'[select PCM by name]'
+  {-q,--quiet}'[quiet mode]'
+  {-t,--file-type}'[file type (voc, wav, raw or au)]'
+  {-c,--channels=}'[channels]'
+  {-r,--rate=}'[sample rate]'
+  {-f,--format=}'[sample format (case insensitive)]'
+  {-d,--duration=}'[interrupt after # seconds]'
+  {-s,--samples=}'[interrupt after # samples per channel]'
+  {-M,--mmap}'[mmap stream]'
+  {-N,--nonblock}'[nonblocking mode]'
+  {-F,--period-time=}'[distance between interrupts is # microseconds]'
+  {-B,--buffer-time=}'[buffer duration is # microseconds]'
+  --period-size='[distance between interrupts is # frames]'
+  --buffer-size='[buffer duration is # frames]'
+  {-A,--avail-min=}'[min available space for wakeup is # microseconds]'
+  {-R,--start-delay=}'[delay for automatic PCM start is # microseconds]'
+  {-T,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]'
+  {-v,--verbose}'[show PCM structure and setup (accumulative)]'
+  {-V,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]'
+  {-I,--separate-channels}'[file for each channel]'
+  {-i,--interactive}'[allow interactive operation from stdin]'
+  {-m,--chmap=}'[give the channel map to override or follow]'
+  --disable-resample'[disable automatic rate resample]'
+  --disable-channels'[disable automatic channel conversions]'
+  --disable-format'[disable automatic format conversions]'
+  --disable-softvol'[disable software volume control (softvol)]'
+  --test-position'[test ring buffer position]'
+  --test-coef='[test coefficient for ring buffer position (default 8)]'
+  --test-nowait'[do not wait for ring buffer - eats whole CPU]'
+  --max-file-time='[start another output file when the old file has recorded]'
+  --process-id-file'[write the process ID here]'
+  --use-strftime'[apply the strftime facility to the output file name]'
+  --dump-hw-params'[dump hw_params of the device]'
+  --fatal-errors'[treat all errors as fatal]'
+
+  '*:sound file:_files'
+)
+
+_arguments -s $opts
+
+# The return value passes through
-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-02 21:13 Completion for aplay from alsa-utils Sebastian Gniazdowski
@ 2019-11-03 23:17 ` dana
  2019-11-04 10:38   ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2019-11-03 23:17 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On 2 Nov 2019, at 16:13, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> the submitted completion is in file _alsa-utils

Feels like maybe it should just be called _aplay, unless you think there would
be so much shared code between future alsa-utils completion functions that
they all need to live together in one (not sure but doesn't seem like it)

And you can add arecord to #compdef, since it's basically the same thing as
aplay

Some functional issues i noticed:

* _arguments should have -S

* There are no exclusions for any of the alias options (e.g., -D and --device
  should be exclusive)

* --device, --file-type, and --process-id-file should take arguments

* All short aliases of long options that take an argument should have + (e.g.,
  -c+ for --channels=)

* -v is cumulative, but there is no * in the spec

Would also be nice to have better optarg completion (there are no argument
descriptions, some of the options take pre-defined arguments that are listed
in the documentation that you could offer, &c.), and taking the option
descriptions from the help output verbatim doesn't look that nice here, but
i'm probably being too pedantic now

dana


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-03 23:17 ` dana
@ 2019-11-04 10:38   ` Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2019-11-04 10:38 UTC (permalink / raw)
  To: Sebastian Gniazdowski, Zsh hackers list

dana wrote:
> On 2 Nov 2019, at 16:13, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > the submitted completion is in file _alsa-utils
>
> Feels like maybe it should just be called _aplay, unless you think there would
> be so much shared code between future alsa-utils completion functions that
> they all need to live together in one (not sure but doesn't seem like it)

I don't agree on this point.
There often is shared code between utilities that come from the same
source. As you even point out, arecord takes essentially the same set of
options. And _alsa-utils makes it clearer where aplay comes from if it
isn't clear. We've also got plenty of existing functions where naming
matches to package or source rather than the command. It can also make
it easier to handle name clashes if a different aplay turns up.

Oliver

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 21:13 Completion for aplay from alsa-utils Sebastian Gniazdowski
2019-11-03 23:17 ` dana
2019-11-04 10:38   ` Oliver Kiddle

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git