From ecbde508d2c3bef82df08ff3af2c1f0b035c7431 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 15 Sep 2017 20:00:57 +0200 Subject: [PATCH] [modules/title] Python < 3.4 compatibility Replace textwrap.shorten() with custom implementation, since it is only available since Python 3.4. While at it, catch i3 exceptions in order to make unit tests (hopefully) run through. Also, Updated README.md see #174 --- README.md | 2 +- bumblebee/modules/title.py | 15 +++++++-------- screenshots/title.png | Bin 0 -> 4458 bytes 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 screenshots/title.png diff --git a/README.md b/README.md index 001cb69..27e8f1b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Test Coverage](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/coverage.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage) [![Issue Count](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/issue_count.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status) -**Many, many thanks to all contributors! As of now, 21 of the modules are from various contributors (!), and only 16 from myself.** +**Many, many thanks to all contributors! As of now, 22 of the modules are from various contributors (!), and only 16 from myself.** bumblebee-status is a modular, theme-able status line generator for the [i3 window manager](https://i3wm.org/). diff --git a/bumblebee/modules/title.py b/bumblebee/modules/title.py index 0bf0589..959c44a 100644 --- a/bumblebee/modules/title.py +++ b/bumblebee/modules/title.py @@ -15,7 +15,6 @@ try: except ImportError: pass -import textwrap import bumblebee.util import bumblebee.input import bumblebee.output @@ -33,13 +32,13 @@ class Module(bumblebee.engine.Module): self._i3 = i3ipc.Connection() self._full_title = self._i3.get_tree().find_focused().name - def focused_title(self): - """Truncates and returns proper-length title.""" - return textwrap.shorten( - self._full_title, - width=float(self.parameter("max", 64)), - placeholder=self.parameter("placeholder", "...") - ) + def focused_title(self, widget): + title = self._full_title[0:self.parameter("max", 64)] + if title != self._full_title: + title = self._full_title[0:self.parameter("max", 64) - 3] + title = "{}...".format(title) + + return title def update(self, widgets): """Update current title.""" diff --git a/screenshots/title.png b/screenshots/title.png new file mode 100644 index 0000000000000000000000000000000000000000..1089a0b9a9d1e341475511f46169a1d46bedd23e GIT binary patch literal 4458 zcmZ8lWmpt#*c~YmX=zv*mTn{j(FK?8?k*{5mR3Z%yFp4C7LjH_Us$A3x*KU&N~FH^ zd*46b_h)9Fxu0vUnK|b^&v{OihMGJ99t|D<00fE(a#{d@>4?6j#Kk}#>A4aY(I-q# zh@uWIF7EuQ`U-kT?DfjPOWV!P%h%Gw7SML^_VTjzuzol82mnZM6y;v(_{|;UIlj8ALnERQp%a~&rt8lrhCb-@WOjbFJN9zTczN{IndG=9{%W6{ZF-5hm#y{k} z*w`cwUg|v{u}NZk&&y+}hzb@Lfii-rWa}^Umdgb^x3aQA@`X=rMur|>syG8!7;j%N z660bC;n!y-{jCW2y#L=a#@p^0lK-Y+Sj+#vi7#InDn`k%LO_g(_iQ$W zSj7DbPr5uuX9NdsWc2s(?V6g4O+r|IM{L)5tdY9KXio1)KfHXE`^oWB44y<6o0m*+ z)FYtVqJF8?)s^t)Clrc}oZOxtIq_74ar(M#6m|N?Xbj>3^_Np21Av5#C}yddu~XIgYnH9|Kp@Ea?wc^oeG;HTS-;-@3}BL=z4>=vzq33`0tsmFH=nI zTL^EK_V$2(f)mDXJA+i>`Y-`F>hxo6Z25CJ1h9o5%nhe z?CdO3lY}s$m{Wr`C&xySl{9H=V(wkZU<&7xa{_g!{G>4TQZ4Pv5%6aF z`#Ly_KXFh&&Z>W_CJS~OR-MZej$E%@Xo_<~1W*+hMUw_ywh?&aGfZ)d8?liM*Nfs^{FS!eI6C~oWYk3HKrNF zTeF60213<*^ug_qzk4*~%#F{cW!>Xlr9jwyy?u-MlL*TiS~)qqLMYpx1#Z*toEhaq zDk^Kz3VYCK6>pE+v2?j(&@ay;S5I1swb~VmI!vXt;6j-U@IP3a$?+%ev#n#n84C9(Lfy@4|JPVM0|zw>HVuvG~tz2A@XrWXUmpaGv$q9I2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