1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00
Clementine-audio-player-Mac.../scripts/shutdown/main.py
2011-05-30 14:53:18 +00:00

31 lines
758 B
Python

import clementine
from PythonQt.QtGui import QAction
import logging
import sys
LOGGER = logging.getLogger("system-shutdown")
class Plugin:
def __init__(self):
self.enabled = False
clementine.player.connect("PlaylistFinished()", self.PlaylistFinished)
self.action = QAction("Shutdown at end", None)
self.action.setCheckable(True)
self.action.connect("triggered(bool)", self.Enabled)
clementine.ui.AddAction("playlist_menu", self.action)
def PlaylistFinished(self):
if self.enabled:
LOGGER.info("Reached the end of the playlist - shutting down")
sys.exit(0)
def Enabled(self, enabled):
LOGGER.info("Shutdown at end of playlist enabled: %s" % str(enabled))
self.enabled = enabled
plugin = Plugin()