From 7263596cb1c6f5a0b5a72044df6e3cb72d20cb6c Mon Sep 17 00:00:00 2001 From: me Date: Fri, 3 Jan 2020 00:17:35 +0200 Subject: [PATCH] [modules/cmus] add file tags --- bumblebee/modules/cmus.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bumblebee/modules/cmus.py b/bumblebee/modules/cmus.py index eca4100..94e7bae 100644 --- a/bumblebee/modules/cmus.py +++ b/bumblebee/modules/cmus.py @@ -7,11 +7,18 @@ Requires the following executable: Parameters: * 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. """ from collections import defaultdict +import os import string import bumblebee.util @@ -78,6 +85,14 @@ class Module(bumblebee.engine.Module): return returns.get(widget.name, self._status) 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] if name == "status":