commit
776824323b
3 changed files with 50 additions and 0 deletions
|
@ -6,6 +6,7 @@ python:
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.6"
|
- "3.6"
|
||||||
install:
|
install:
|
||||||
|
- pip install i3ipc
|
||||||
- pip install psutil
|
- pip install psutil
|
||||||
- pip install netifaces
|
- pip install netifaces
|
||||||
- pip install -U coverage==4.3
|
- pip install -U coverage==4.3
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
48
bumblebee/modules/title.py
Normal file
48
bumblebee/modules/title.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# pylint: disable=C0111,R0903
|
||||||
|
|
||||||
|
"""Displays focused i3 window title.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
* i3ipc
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
* title.max : Maximum character length for title before truncating. Defaults to 64.
|
||||||
|
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to "...".
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
import i3ipc
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
import bumblebee.util
|
||||||
|
import bumblebee.input
|
||||||
|
import bumblebee.output
|
||||||
|
import bumblebee.engine
|
||||||
|
|
||||||
|
class Module(bumblebee.engine.Module):
|
||||||
|
"""Window title module."""
|
||||||
|
|
||||||
|
def __init__(self, engine, config):
|
||||||
|
super(Module, self).__init__(
|
||||||
|
engine,
|
||||||
|
config,
|
||||||
|
bumblebee.output.Widget(full_text=self.focused_title)
|
||||||
|
)
|
||||||
|
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 update(self, widgets):
|
||||||
|
"""Update current title."""
|
||||||
|
self._full_title = self._i3.get_tree().find_focused().name
|
||||||
|
|
||||||
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
Loading…
Reference in a new issue