9
9
* title.max : Maximum character length for title before truncating. Defaults to 64.
10
10
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to '...'.
11
11
* 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
13
13
14
14
15
15
contributed by `UltimatePancake <https://github.com/UltimatePancake>`_ - many thanks!
@@ -36,16 +36,21 @@ def __init__(self, config, theme):
36
36
37
37
# parsing of parameters
38
38
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
+ )
40
42
self .__max = int (self .parameter ("max" , 64 ))
41
43
self .__placeholder = self .parameter ("placeholder" , "..." )
42
44
self .__title = ""
45
+ self .__prefix = util .format .asbool (self .parameter ("short" ) == "prefix" )
43
46
44
47
# set output of the module
45
48
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
+ )
49
54
)
50
55
51
56
# create a connection with i3ipc
@@ -70,8 +75,14 @@ def __pollTitle(self):
70
75
"""Updating current title."""
71
76
try :
72
77
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
+ )
75
86
except :
76
87
self .__full_title = no_title
77
88
if self .__full_title is None :
0 commit comments