Save Playlist Automatically

Bug #669132 reported by Diego Rocha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pogo
Fix Released
Wishlist
Unassigned

Bug Description

Put this as "Wishlist", but I have to close Pogo to save my current playlist, so if I just shutdown my pc instead of closing Pogo first, I will lose my selection. Small things make a good software :)

P.S.: I didn't even noticed that pogo is faster now because it already opened FASTER than my compiz animation to open a new window!

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

Nevermind, it's already in TODO....

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

The item in the TODO list actually stands for exporting the playlist to m3u.

Pogo already saves the playlist when the signals SIGTERM or SIGINT are sent to it. I don't know which signal is sent to Pogo, when the OS shuts down, but I'm pretty sure it's first SIGTERM and then SIGKILL. If only the signal SIGKILL is sent, then nothing can be done, because this signal cannot be caught.

Can you try if Pogo saves your playlist on shutdown with the latest development code?

Changed in pogo:
status: New → Incomplete
Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I tried and it doesn't save the playlist. To make this work, I think you will need to make it save the playlist everytime a music is added or deleted. Would this cause any performance issue?

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

See if you can reproduce this.

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

Maybe you could try to find out which signal Ubuntu sends on shutdown?

Saving the playlist everytime is not desirable, I think.

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I tested SIGTERM and SIGKILL, in neither pogo saves the playlist. From what I found on the internet, Ubuntu sends SIGTERM then SIGKILL, so you could trap SIGTERM, using something like this: http://ubuntuforums.org/showthread.php?t=1436304

I made a video of my test:
https://dl.dropbox.com/u/10732001/signal.ogv
(9 is SIGKILL and 15 is SIGTERM)

This may be useful:
http://www.gnu.org/s/libc/manual/html_node/Termination-Signals.html

I hope this helps

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

Try this:
import signal

def handleSigTERM():
    atExit()

signal.signal(signal.SIGTERM, handleSigTERM)

but with the proper function. "atExit()" doesn't seem to be the function that saves the playslist (too lazy to search, plus is pretty late already).

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

Actually this code already exists in pogo.py

I'll try to reproduce the error over here first.

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I made a mistake! I used kill -9 15 ID when I should have used kill 15 ID. SIGTERM will save the playlist and SIGKILL won't! My bad, sorry...

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

And is the playlist saved even at OS shutdown?

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

No, it isn't... it seems that OS Shutdown = SIGKILL

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

Yes, here too. My playlist is not saved at shutdown. Hmm, there doesn't seem to be a way to do it...

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I noticed that not even Google Chrome can save anything at shutdown since if I turn off my pc with Chrome opened, when I open Chrome again it will say that it wasn't terminated correctly. Maybe Pogo could save the playlist from time to time, like every 3 minutes.

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

I like the idea. Let's put it on the wishlist.

Changed in pogo:
importance: Undecided → Wishlist
status: Incomplete → Confirmed
Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I changed pogo.py to make it save every minute. http://dl.dropbox.com/u/10732001/pogo.py

I added this:

    def save():
        media.save( files, "~/.config/pogo/saved-playlist")
 return True

    gtk.timeout_add(60*1000, save)

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

I will test it a little.... really don't know if it is working properly, yet

Revision history for this message
Diego Rocha (diego-rocha-393) wrote :

No, it isn't.... here we go again.... when I have something, I return

Revision history for this message
Jendrik Seipp (jendrikseipp) wrote :

I implemented this in trunk. Playlist is saved every 10 minutes for now.

Changed in pogo:
status: Confirmed → Fix Committed
Changed in pogo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.