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

Run less frequently (only on album change) #51

Open
dextre opened this issue Nov 30, 2020 · 0 comments
Open

Run less frequently (only on album change) #51

dextre opened this issue Nov 30, 2020 · 0 comments

Comments

@dextre
Copy link

dextre commented Nov 30, 2020

Due to the broadness of mpc idle player, kunst currently runs every song change, play state change, or just seeking within a song. If you seek or skip tracks on albums often, it can needlessly run dozens of times when the cover hasn't changed once. This gets more wasteful if you're dealing with very large files or resolutions.

On some artwork (small ones it has to scale up?) I've noticed a flash of sxivs background color while its switching art, which gets really distracting at fullscreen when it happens every seek or song change.

To remedy these I've made mine only run when the album changes like so:

ALBUM="$(dirname "$(mpc current -f %file%)")"
mpc idle player &>/dev/null && (mpc status | grep "\[playing\]" &>/dev/null) && sleep .3 && if [ "$ALBUM" != "$(dirname "$(mpc current -f %file%)")" ]; then break; fi

This prevents the vast majority of find_album_art runs.
I'm using the album path for ALBUM as a personal preference, but a more universal way (since many people keep a bunch of random tracks in one dir) could be:
mpc current -f "[[%albumartist% - |%artist% - ]%album%]|%file%"
This should try AlbumArtist - Album to not update on every track change on multi-artist compilations, then Artist or just Album if they exist, or falls back to just file path on songs missing all tags (which updates on every track change).

Alternatively, to only fix the run-every-seek issue, you could keep track of song changes like "$SONG" != "$(mpc current -f %file%)". Though only running on album changes is much more efficient. Ideally there could be an option to toggle between or disable the feature.

I'm posting this as a suggestion not a PR because I'm a bash & git noob and I'm sure my if method can be improved by someone. I added a sleep .3 in my example above because in some circumstances it was not detecting an album change (I'm not sure why, could be because my mpd is on another pc across the network), adding the delay seemed to fix mine.

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

1 participant