Showing song length and elapsed time in notification #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to know easily the length and the elapsed time of the song I am currently listening to. Therefore I modified the code to show the length of the song when mpd state changed and to show elapsed time and length of the song when the signal SIGHUP is sent to mpd-notification.
The information on the length and elapsed time of the song is not shown by default. It can be activated in the configuration file with
show-time = true
.Since the notification object was not updated when a signal was sent to mpd-notification, I factorized out of the
main
function the update of the notification object and called the newly created function from the signal handler. This way, the correct elapsed time is shown when a signal is sent to the process. Some variable, such asmusic_dir
, were made global to make them accessible from the function that update the notification.If something must be changed in my code, I will gladly modify it.