[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
This commit is contained in:
parent
776824323b
commit
ecbde508d2
3 changed files with 8 additions and 9 deletions
|
@ -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/).
|
||||
|
||||
|
|
|
@ -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."""
|
||||
|
|
BIN
screenshots/title.png
Normal file
BIN
screenshots/title.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in a new issue