diff --git a/lib/awful/widget/tasklist.lua b/lib/awful/widget/tasklist.lua index 41998c777..5d269458a 100644 --- a/lib/awful/widget/tasklist.lua +++ b/lib/awful/widget/tasklist.lua @@ -491,6 +491,11 @@ local function tasklist_update(s, self, buttons, filter, data, style, update_fun end end + if self._private.last_count ~= #clients then + self:emit_signal("property::count", #clients, self._private.last_count) + self._private.last_count = #clients + end + local function label(c, tb) return tasklist_label(c, style, tb) end update_function(self._private.base_layout, buttons, label, data, clients, { @@ -499,6 +504,13 @@ local function tasklist_update(s, self, buttons, filter, data, style, update_fun }) end +--- The current number of clients. +-- +-- @property count +-- @readonly +-- @tparam number The number of client. +-- @propemits true false + --- Set the tasklist layout. -- -- @property base_layout @@ -559,6 +571,14 @@ function tasklist:set_base_layout(layout) self:emit_signal("property::base_layout", layout) end +function tasklist:get_count() + if not self._private.last_count then + self._do_tasklist_update_now() + end + + return self._private.last_count +end + function tasklist:layout(_, width, height) if self._private.base_layout then return { base.place_widget_at(self._private.base_layout, 0, 0, width, height) }