Skip to content

Commit

Permalink
Move widget configurations to _configure
Browse files Browse the repository at this point in the history
The `Mpd2` and `PulseVolume` widgets have code in their `__init__`
methods that is better suited to the `_configure` method.
  • Loading branch information
elParaguayo committed Sep 21, 2022
1 parent f741306 commit 6c20b89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libqtile/widget/mpd2widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,14 @@ def __init__(self, **config):
super().__init__("", **config)

self.add_defaults(Mpd2.defaults)
if self.color_progress:
self.color_progress = utils.hex(self.color_progress)

def _configure(self, qtile, bar):
super()._configure(qtile, bar)
self.client = MPDClient()
self.client.timeout = self.timeout
self.client.idletimeout = self.idletimeout
if self.color_progress:
self.color_progress = utils.hex(self.color_progress)

@property
def connected(self):
Expand Down
2 changes: 2 additions & 0 deletions libqtile/widget/pulse_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def __init__(self, **config):
self.handle = ffi.new_handle(self)
self.client_name = ffi.new("char[]", b"Qtile-pulse")

def _configure(self, qtile, bar):
Volume._configure(self, qtile, bar)
self.connect()

def finalize(self):
Expand Down

0 comments on commit 6c20b89

Please sign in to comment.