[module/title] added scrollable title option
This commit is contained in:
parent
4a9782a517
commit
da21eba0d7
1 changed files with 17 additions and 3 deletions
|
@ -8,6 +8,7 @@ Requirements:
|
||||||
Parameters:
|
Parameters:
|
||||||
* title.max : Maximum character length for title before truncating. Defaults to 64.
|
* 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.placeholder : Placeholder text to be placed if title was truncated. Defaults to "...".
|
||||||
|
* title.scroll : Boolean flag for scrolling title. Defaults to False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -20,6 +21,8 @@ import bumblebee.input
|
||||||
import bumblebee.output
|
import bumblebee.output
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
|
|
||||||
|
from bumblebee.output import scrollable
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
"""Window title module."""
|
"""Window title module."""
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ class Module(bumblebee.engine.Module):
|
||||||
super(Module, self).__init__(
|
super(Module, self).__init__(
|
||||||
engine,
|
engine,
|
||||||
config,
|
config,
|
||||||
bumblebee.output.Widget(full_text=self.focused_title)
|
bumblebee.output.Widget(full_text=self.get_title)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
self._i3 = i3ipc.Connection()
|
self._i3 = i3ipc.Connection()
|
||||||
|
@ -35,14 +38,25 @@ class Module(bumblebee.engine.Module):
|
||||||
except Exception:
|
except Exception:
|
||||||
self._full_title = "n/a"
|
self._full_title = "n/a"
|
||||||
|
|
||||||
|
def get_title(self, widget):
|
||||||
|
if self.parameter("scroll", "False").lower() == "true":
|
||||||
|
return self.scrolling_focused_title(widget)
|
||||||
|
else:
|
||||||
|
return self.focused_title(widget)
|
||||||
|
|
||||||
def focused_title(self, widget):
|
def focused_title(self, widget):
|
||||||
title = self._full_title[0:self.parameter("max", 64)]
|
title = self._full_title[0:self.parameter("max", 64)]
|
||||||
|
placeholder = self.parameter("placeholder", "...")
|
||||||
if title != self._full_title:
|
if title != self._full_title:
|
||||||
title = self._full_title[0:self.parameter("max", 64) - 3]
|
title = self._full_title[0:self.parameter("max", 64) - len(placeholder)]
|
||||||
title = "{}...".format(title)
|
title = "{}{}".format(title, placeholder)
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
@scrollable
|
||||||
|
def scrolling_focused_title(self, widget):
|
||||||
|
return self._full_title
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
"""Update current title."""
|
"""Update current title."""
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue