[module/title] Requirement update in README.md + linting
This commit is contained in:
parent
55f48d5618
commit
8bba1d1e0d
2 changed files with 6 additions and 3 deletions
|
@ -108,6 +108,7 @@ Modules and commandline utilities are only required for modules, the core itself
|
||||||
* requests (for the modules 'weather', 'github', 'getcrypto', 'stock')
|
* requests (for the modules 'weather', 'github', 'getcrypto', 'stock')
|
||||||
* power (for the module 'battery')
|
* power (for the module 'battery')
|
||||||
* dbus (for the module 'spotify')
|
* dbus (for the module 'spotify')
|
||||||
|
* i3rpc (for the module 'title')
|
||||||
|
|
||||||
# Required commandline utilities
|
# Required commandline utilities
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,25 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
import textwrap
|
||||||
import bumblebee.util
|
import bumblebee.util
|
||||||
import bumblebee.input
|
import bumblebee.input
|
||||||
import bumblebee.output
|
import bumblebee.output
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
import textwrap
|
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
"""Window title module."""
|
"""Window title module."""
|
||||||
|
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
super(Module, self).__init__(engine, config,
|
super(Module, self).__init__(
|
||||||
|
engine,
|
||||||
|
config,
|
||||||
bumblebee.output.Widget(full_text=self.focused_title)
|
bumblebee.output.Widget(full_text=self.focused_title)
|
||||||
)
|
)
|
||||||
self._i3 = i3ipc.Connection()
|
self._i3 = i3ipc.Connection()
|
||||||
self._full_title = self._i3.get_tree().find_focused().name
|
self._full_title = self._i3.get_tree().find_focused().name
|
||||||
|
|
||||||
def focused_title(self, widget):
|
def focused_title(self):
|
||||||
"""Truncates and returns proper-length title."""
|
"""Truncates and returns proper-length title."""
|
||||||
return textwrap.shorten(
|
return textwrap.shorten(
|
||||||
self._full_title,
|
self._full_title,
|
||||||
|
|
Loading…
Reference in a new issue