[modules/cmus] add file tags

This commit is contained in:
me 2020-01-03 00:17:35 +02:00
parent 231407f6da
commit 7263596cb1

View file

@ -7,11 +7,18 @@ Requires the following executable:
Parameters: Parameters:
* cmus.format: Format string for the song information. Tag values can be put in curly brackets (i.e. {artist}) * cmus.format: Format string for the song information. Tag values can be put in curly brackets (i.e. {artist})
Additional tags:
* {file} - full song file name
* {file1} - song file name without path prefix
if {file} = '/foo/bar.baz', then {file1} = 'bar.baz'
* {file2} - song file name without path prefix and extension suffix
if {file} = '/foo/bar.baz', then {file2} = 'bar'
* cmus.layout: Space-separated list of widgets to add. Possible widgets are the buttons/toggles cmus.prev, cmus.next, cmus.shuffle and cmus.repeat, and the main display with play/pause function cmus.main. * cmus.layout: Space-separated list of widgets to add. Possible widgets are the buttons/toggles cmus.prev, cmus.next, cmus.shuffle and cmus.repeat, and the main display with play/pause function cmus.main.
""" """
from collections import defaultdict from collections import defaultdict
import os
import string import string
import bumblebee.util import bumblebee.util
@ -78,6 +85,14 @@ class Module(bumblebee.engine.Module):
return returns.get(widget.name, self._status) return returns.get(widget.name, self._status)
def _eval_line(self, line): def _eval_line(self, line):
if line.startswith("file "):
full_file = line[5:]
file1 = os.path.basename(full_file)
file2 = os.path.splitext(file1)[0]
self._tags.update({"file": full_file})
self._tags.update({"file1": file1})
self._tags.update({"file2": file2})
return
name, key, value = (line.split(" ", 2) + [None, None])[:3] name, key, value = (line.split(" ", 2) + [None, None])[:3]
if name == "status": if name == "status":