1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-28 02:21:14 +01:00
Clementine-audio-player-Mac.../scripts/shutdown/main.py

31 lines
758 B
Python
Raw Normal View History

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()