mpd and title

This commit is contained in:
Dhananjay Tanpure 2022-03-07 08:50:30 +05:30
parent 8867f4f188
commit e5cdabcc0f
No known key found for this signature in database
GPG key ID: 4CCF71A10B0E84B6
2 changed files with 14 additions and 1 deletions

View file

@ -9,6 +9,7 @@ Parameters:
* title.max : Maximum character length for title before truncating. Defaults to 64.
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to '...'.
* title.scroll : Boolean flag for scrolling title. Defaults to False
* title.short : Boolean flag for short title. Defaults to False
contributed by `UltimatePancake <https://github.com/UltimatePancake>`_ - many thanks!
@ -35,6 +36,7 @@ class Module(core.module.Module):
# parsing of parameters
self.__scroll = util.format.asbool(self.parameter("scroll", False))
self.__short = util.format.asbool(self.parameter("short", False))
self.__max = int(self.parameter("max", 64))
self.__placeholder = self.parameter("placeholder", "...")
self.__title = ""
@ -66,7 +68,9 @@ class Module(core.module.Module):
def __pollTitle(self):
"""Updating current title."""
try:
self.__full_title = self.__i3.get_tree().find_focused().name
focused = self.__i3.get_tree().find_focused().name
self.__full_title = focused.split(
"-")[-1].strip() if self.__short else focused
except:
self.__full_title = no_title
if self.__full_title is None: