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
107 stars 10 forks source link

content inset from left edge of terminal #5

Closed joeldcanfield closed 1 year ago

joeldcanfield commented 1 year ago

Describe the bug each line of the player begins at between 27 and 32 spaces from the left edge of the terminal

To Reproduce running zsh am.sh np (default usage)

Expected behavior text should be left justified

Desktop (please complete the following information):

I cannot determine from the code what's causing the indenting. This behavior is probably by design, not a bug, but either way I would appreciate knowing how to adjust the appearance of the player, particularly, the indentation. Thanks very much. Really love this player.

mcthomas commented 1 year ago

Hi @joeldcanfield, thanks for submitting an issue. Could you please share a screenshot of your terminal running np in a large window? the album art really should be flush to the left side. Glad that you like the player, hopefully we can adjust it to your liking.

Edit: also, what terminal emulator are you using?

joeldcanfield commented 1 year ago

Indeed am sh

joeldcanfield commented 1 year ago

Using Mac's native terminal.

mcthomas commented 1 year ago

Ah, did you install viu? That's a dependency for np, along with the separate album art AppleScript in /src. The text is padded to make room for the album art. If you don't want to, you can run np with the text mode flag.

joeldcanfield commented 1 year ago

d'oh. used it on my first test, then forgot. looking for a pure text tool, so I'll alias and script it so it's text mode.

I'm munging the time played/left display and the volume/mute, shuffle/repeat buttons with text as well. I'm an old command line curmudgeon who likes what he likes.

For my edification, which part of the code does the padding for the album covers? I just couldn't find it.

Another question: is there a "quit" function? I've been doing CTRL-C which isn't elegant, but it works.

mcthomas commented 1 year ago

Currently these calls at line 98 of am.sh: <(printf %s "") handle the padding. BUT, you shouldn't need to remove these, you can just call np with am np -t so that it runs in text-mode, flush to the left side of your terminal window. That would save you some time.

There isn't a keybinding to exit, I think CTRL-C is standard and it would be redundant to add a key for exiting for a bash script. But if you think that's the wrong approach, I'd think about adding a q keybinding.

joeldcanfield commented 1 year ago

No need for a quit key unless the masses clamor. I sort of expected it, but only because it's common, not because it's necessary.

I do see the padding, and the space left for the art. Thanks.

Another question, but please, let me know when you tire of my pestering: the colors set on lines 64-66 use standard bash codes, and I'm wondering if there's a way to have access to all 256 xterm colors, as I do, for instance, with my zsh prompt.

Thanks again for being willing to chat.

mcthomas commented 1 year ago

No worries! I love talking about this stuff. You can call any of the 256 xterm colors the same way, just replace the ANSI color codes in the bash variables. For example: cyan=$(echo -e '\e[00;36m') Could instead include an xterm color code: cyan=$(echo -e '\e[38;5;123m') And that should display correctly if your terminal emulator supports xterm colors.

joeldcanfield commented 1 year ago

Perfect. It does.

I'd skipped past the 8-bit ANSI color coding. Useful. Thanks.

joeldcanfield commented 1 year ago

Rethinking my position on the 'q' option. Currently, I have to hit 'p', then CTRL-C. If I forget to pause the playback, I hit CTRL-C which kills the script but not the player, then after a moment of confusion while the music continues, I look for one of the other ways to stop the Music app.

An option to both stop playback and kill the script would be more elegant and intuitive.

mcthomas commented 1 year ago

np was written as a "widget" because it runs in parallel to Music.app, but it cannot run in place of it. So the philosophy is that you can already have music playing, and decide to run the script. It's an optional controller, but playback can be played or paused universally with the special Fn keys / Touch Bar, or within Music.app itself. With that in mind, I wouldn't want the script to halt a user's playback just because they sent a kill signal to the np widget.

I feel that an option to just kill the script could be useful though, thank you for that suggestion.

joeldcanfield commented 1 year ago

Understood. I've been modifying my copy of the script visually. Might continue making some changes just for my own use, if that doesn't feel invasive and impertinent to you.

mcthomas commented 1 year ago

Yes of course! Feel free to fork it too!