eworm-de / mpd-notification

Notify about tracks played by mpd
GNU General Public License v3.0
86 stars 23 forks source link

Showing song length and elapsed time in notification #24

Open Poroing opened 6 years ago

Poroing commented 6 years ago

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 as music_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.

Poroing commented 4 years ago

I've made the pull request ready for merge in the base branch again.

@eworm-de I hope you can go over it and tell me what needs to be changed or what you don't like about the change. Would you like me to change the README.md in the pull request to let the user know about this change?