Skip to content

Commit 950b31d

Browse files
Merge pull request #1044 from theymightbetim/Issue-1034
Issue 1034 - feat: Short Title Prefix
2 parents 1c68500 + febedea commit 950b31d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

bumblebee_status/modules/contrib/title.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* title.max : Maximum character length for title before truncating. Defaults to 64.
1010
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to '...'.
1111
* title.scroll : Boolean flag for scrolling title. Defaults to False
12-
* title.short : Boolean flag for short title. Defaults to False
12+
* title.short : True || False || prefix. Defaults to False
1313
1414
1515
contributed by `UltimatePancake <https://github.com/UltimatePancake>`_ - many thanks!
@@ -36,16 +36,21 @@ def __init__(self, config, theme):
3636

3737
# parsing of parameters
3838
self.__scroll = util.format.asbool(self.parameter("scroll", False))
39-
self.__short = util.format.asbool(self.parameter("short", False))
39+
self.__short = util.format.asbool(
40+
self.parameter("short") == True and self.parameter("short") != "prefix"
41+
)
4042
self.__max = int(self.parameter("max", 64))
4143
self.__placeholder = self.parameter("placeholder", "...")
4244
self.__title = ""
45+
self.__prefix = util.format.asbool(self.parameter("short") == "prefix")
4346

4447
# set output of the module
4548
self.add_widget(
46-
full_text=self.__scrolling_focused_title
47-
if self.__scroll
48-
else self.__focused_title
49+
full_text=(
50+
self.__scrolling_focused_title
51+
if self.__scroll
52+
else self.__focused_title
53+
)
4954
)
5055

5156
# create a connection with i3ipc
@@ -70,8 +75,14 @@ def __pollTitle(self):
7075
"""Updating current title."""
7176
try:
7277
focused = self.__i3.get_tree().find_focused().name
73-
self.__full_title = focused.split(
74-
"-")[-1].strip() if self.__short else focused
78+
self.__full_title = (
79+
focused.split("-")[-1].strip() if self.__short else focused
80+
)
81+
self.__full_title = (
82+
self.__full_title.split(" -")[0].strip()
83+
if self.__prefix
84+
else self.__full_title
85+
)
7586
except:
7687
self.__full_title = no_title
7788
if self.__full_title is None:

docs/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ Parameters:
17681768
* title.max : Maximum character length for title before truncating. Defaults to 64.
17691769
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to '...'.
17701770
* title.scroll : Boolean flag for scrolling title. Defaults to False
1771-
* title.short : Boolean flag for short title. Defaults to False
1771+
* title.short : true/false/prefix. Defaults to False
17721772

17731773

17741774
contributed by `UltimatePancake <https://github.com/UltimatePancake>`_ - many thanks!

0 commit comments

Comments
 (0)