Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read note information from beep file (with #! support if at all possible) #18

Open
xssfox opened this issue Jan 13, 2021 · 6 comments
Open
Assignees

Comments

@xssfox
Copy link

xssfox commented Jan 13, 2021

Not sure how to explain this apart from as an example. I'd like to do something like

#!/usr/bin/beep
-f 1006.25 -l 160.0 -d 0 -D 0 
-f 1025.0 -l 160.0 -d 0 -D 0 
-f 1000.0 -l 160.0 -d 0 -D 0 
-f 1037.5 -l 160.0 -d 0 -D 0 
-f 1031.25 -l 160.0 -d 0 -D 0 -n -f 1031.25 -l 160.0 -d 0 -D 0 
-f 1012.5 -l 160.0 -d 0 -D 0 
-f 1018.75 -l 160.0 -d 0 -D 0 
-f 1012.5 -l 160.0 -d 0 -D 0 

Basically, have beep read the file or from stdin with the beep commands, and play the tones accordingly on each new line or -n

@ndim
Copy link
Member

ndim commented Jan 13, 2021

You can already do almost the same thing using xargs from GNU findutils:

[user@host ~]$ cat beep-file 
-f 1006.25 -l 160.0 -d 0 -D 0
-f 1025.0 -l 160.0 -d 0 -D 0
-f 1000.0 -l 160.0 -d 0 -D 0
-f 1037.5 -l 160.0 -d 0 -D 0
-f 1031.25 -l 160.0 -d 0 -D 0 -n -f 1031.25 -l 160.0 -d 0 -D 0
-f 1012.5 -l 160.0 -d 0 -D 0
-f 1018.75 -l 160.0 -d 0 -D 0
-f 1012.5 -l 160.0 -d 0 -D 0
[ 18:37:57 | 1036 | 0 | ~ ]
[user@host ~]$ xargs -l beep < beep-file
[user@host ~]$ xargs -t -l beep < beep-file
beep -f 1006.25 -l 160.0 -d 0 -D 0 
beep -f 1025.0 -l 160.0 -d 0 -D 0 
beep -f 1000.0 -l 160.0 -d 0 -D 0 
beep -f 1037.5 -l 160.0 -d 0 -D 0 
beep -f 1031.25 -l 160.0 -d 0 -D 0 -n -f 1031.25 -l 160.0 -d 0 -D 0 
beep -f 1012.5 -l 160.0 -d 0 -D 0 
beep -f 1018.75 -l 160.0 -d 0 -D 0 
beep -f 1012.5 -l 160.0 -d 0 -D 0 
[user@host ~]$ 

Admittedly, not every implementation of xargs implements -L or -l (e.g. busybox xargs), and you cannot just use #!/usr/bin/xargs -l beep as the first line of an executable script due to the part after the first space in that line being used as a single string parameter to the part before the first space.

Does integrating parts of the xargs functionality into beep really make sense?

@ndim ndim self-assigned this Jan 13, 2021
@xssfox
Copy link
Author

xssfox commented Jan 13, 2021 via email

@ndim
Copy link
Member

ndim commented Jan 14, 2021

That is a very valid point. Do you expect your file length to ever potentially exceed 2KB or 4KB?

@xssfox
Copy link
Author

xssfox commented Jan 14, 2021

hmm. It currently sits just below 4KB

@ndim
Copy link
Member

ndim commented Jan 14, 2021

OK, that rules out something along the lines of

beep $(python -c "print(' -n '.join([s.strip() for s in open('beep-file').readlines()]))")

for system with older shells, as those had limits on the maximum length of the command line around the 4K mark.

Are you writing those files by hand, or are those files generated from something else? We could either try to find a less verbose way of writing notes, or go one level further and process something closer to your source.

Or I could alter beep after all in a way such that it can read notes not just from the command line but also from files, maybe with a new way of writing the notes (see #19).

@xssfox
Copy link
Author

xssfox commented Jan 14, 2021

These are generated using a python script at the moment but the intent is to be able to have a script that anyone can run provided they have beep installed.

When I was testing with a windows beep app it used freq duration \s sleep freq duration \s sleep freq duration \s sleep ... where \s sleep is an optional delay between notes

@ndim ndim changed the title beep file read note information from beep file (with #! support if at all possible) Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants