-
Notifications
You must be signed in to change notification settings - Fork 28
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
Use mpc idle
instead of polling
#28
Comments
I don't have enough time to do it now, but you are welcome to try. If you were to implement this you'd probably have to use On a sidenote, I have some uncommitted changes with on-screen widget. That code obviously requires constant polling as widget stays on the screen permanently. So I'm not sure in the end this implementation will fit all the usecases. |
Incorperated updates from https://github.com/alexander-yakushev/awesomerc/blob/master/awesompd/awesompd.lua Made slight alterations & bugfixes (escape formated string -> format escaped string) Added a protect_strings() which is capable of escaping & returning stiring lists. TODO Store os.time when track_passed is stored. Can be used to keep a relitivly accurate track position on osd and notify without calling update_track. Try implementing alexander-yakushev#28 (mpc idle/idleloop instead of update_track). should give near instant track change(play/pause/stop/next/prev) notifications regardless of means of changing track (track ended, mpc or ario client request)
I saw this within an hour of merging. If your still interested, I seem to have working code, though it could use a look over from someone who knows what asyncshell.lua is doing. |
idle_update() handles running update_track on track change, pause, play, stop, next, and prev events. It should run near instantly regardless of what clients are used. recalculate_track calculates track_position and track_progress based on how much time has passed since last update_track. Usefull for keeping an osd up to date without excessive calls to update_track. Implements alexander-yakushev#28
I didnt mean to reference this in the first commit. (didn't know I could) Recalculate_track currently sets 'calc_' prefixed vars, meaning non calc_ ones wont using this functionality. Made this while working with the onscreen widget version. Some status_text related things got included since removal looked time-consuming. (wondering why your holding it back, its great! Updates without flickering! if it had ontop =true and x/y pos set relative to mouse on the text widgets mouse::enter event, it may even double as a beautiful notify. ) You may want to bump update_interval up, I set mine to 60 since it shouldn't be necessary(except for syncing time in case mpd plays faster/slower than os.time, which should take a while to be noticeable). It shouldn't hurt to change mouse::enter's update_track to a recalculate_track and set notify_track to use calc_track time and pos. Though having fallback may be a good idea. (I think I'm avoiding writing my English paper the wrong way) Let me know if your interested in any of it, have suggestions or complaints. |
Would it be possible to use
mpc idle
ormpc idleloop
to update the status instead of polling it everyupdate_interval
?The idea is to reduce the number of useless connections created to mpd. Connections would only needed to be made when something has actually changed on the mpd side and to get the current time when the mouse hovers over the widget.
I could even have a look at it myself, if I find a way to execute functions when
mpc idleloop
has new output.The text was updated successfully, but these errors were encountered: