2017-06-12 15:06:56 +02:00
|
|
|
# pylint: disable=C0111,R0903
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-01-14 10:03:47 +01:00
|
|
|
"""Displays information about the current song in mocp. Left click toggles play/pause. Right click toggles shuffle.
|
2017-06-12 15:06:56 +02:00
|
|
|
|
|
|
|
Requires the following executable:
|
|
|
|
* mocp
|
|
|
|
|
|
|
|
Parameters:
|
2019-01-14 09:43:21 +01:00
|
|
|
* mocp.format: Format string for the song information. Replace string sequences with the actual information:
|
|
|
|
%state State
|
|
|
|
%file File
|
|
|
|
%title Title, includes track, artist, song title and album
|
|
|
|
%artist Artist
|
|
|
|
%song SongTitle
|
|
|
|
%album Album
|
|
|
|
%tt TotalTime
|
|
|
|
%tl TimeLeft
|
|
|
|
%ts TotalSec
|
|
|
|
%ct CurrentTime
|
|
|
|
%cs CurrentSec
|
|
|
|
%b Bitrate
|
|
|
|
%r Sample rate
|
2017-06-12 15:06:56 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
import bumblebee.util
|
|
|
|
import bumblebee.input
|
|
|
|
import bumblebee.output
|
|
|
|
import bumblebee.engine
|
|
|
|
|
|
|
|
from bumblebee.output import scrollable
|
|
|
|
|
|
|
|
class Module(bumblebee.engine.Module):
|
|
|
|
def __init__(self, engine, config):
|
2019-01-14 09:43:21 +01:00
|
|
|
super(Module, self).__init__(engine, config,
|
|
|
|
bumblebee.output.Widget(name="mocp.main", full_text=self.description)
|
|
|
|
)
|
2017-06-12 15:06:56 +02:00
|
|
|
|
2019-01-14 09:43:21 +01:00
|
|
|
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
2017-06-12 15:06:56 +02:00
|
|
|
cmd="mocp -G")
|
2019-01-14 10:03:47 +01:00
|
|
|
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE,
|
|
|
|
cmd="mocp -t shuffle")
|
2019-01-14 09:43:21 +01:00
|
|
|
self._format = self.parameter("format", "%state %artist - %song | %ct/%tt")
|
2017-06-12 18:50:08 +02:00
|
|
|
self._running = 0
|
2017-06-12 15:06:56 +02:00
|
|
|
|
|
|
|
#@scrollable
|
|
|
|
def description(self, widget):
|
2019-01-14 09:43:21 +01:00
|
|
|
return self._info if self._running == 1 else "Music On Console Player"
|
2017-06-12 15:06:56 +02:00
|
|
|
|
|
|
|
def update(self, widgets):
|
|
|
|
self._load_song()
|
|
|
|
|
|
|
|
def _load_song(self):
|
|
|
|
try:
|
2019-01-16 05:42:44 +01:00
|
|
|
self._info = bumblebee.util.execute("mocp -Q '" + self._format + "'" ).strip()
|
2019-01-14 09:43:21 +01:00
|
|
|
self._running = 1
|
2017-06-12 15:06:56 +02:00
|
|
|
except RuntimeError:
|
|
|
|
self._running = 0
|
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|