mcthomas / Apple-Music-CLI-Player

A simple command-line Apple Music controller script which includes a "Now Playing" widget function, a playback function, and a list-out function for your Mac's Music.app library, written in sh.
MIT License
114 stars 10 forks source link

am np results in timeout error #4

Closed davidem closed 1 year ago

davidem commented 1 year ago

When I start am np I get the following error: bash: line 0: read: .5: invalid timeout specification

It appears zsh (at least the version i'm running can't handle decimal numbers. If I change the following line input=$(bash -c "read -n 1 -t .5 input; echo \$input | xargs") to input=$(bash -c "read -n 1 -t 1 input; echo \$input | xargs") the error disappears.

macOS 12.6.1 and zsh 5.8.1 (x86_64-apple-darwin21.0)

mcthomas commented 1 year ago

Hi David,

Great catch. Since I have an explicit call to bash, it seems dependent on which version of bash is symlinked. I think I missed this error because my system defaults to a newer bash package from brew. Replacing bash in that line with /bin/bash proves your point, as that is the native package in macOS.

I tried to use the native /bin/zsh for this line, but it seems to break the read cmd. For the time being I will just resolve it to 1, until I find a better solution that accommodates decimals for snappier screen updates. Thanks again for catching this.