OK. Got it working.
Put this in your config file:
from libqtile import qtile
@hook.subscribe.startup_complete
def create_win_count_hooks():
hook.subscribe.client_killed(wincount_kill)
hook.subscribe.client_managed(wincount)
hook.subscribe.current_screen_change(wincount)
hook.subscribe.setgroup(wincount)
wincount()
def wincount(*args):
try:
win_count = len(qtile.current_group.windows)
except AttributeError:
win_count = 0
qtile.widgets_map["window_count"].update(win_count)
def wincount_kill(window):
try:
win_count = len(qtile.current_group.windows)
except AttributeError:
win_count = 0
if win_count and getattr(window, "group", None):
win_count -= 1
qtile.widgets_map["window_count"].update(win_count)
Then create a TextBox widget in your bar:
widget.TextBox(name="window_count", text="")
On Wednesday, 25 November 2020 at 07:26:17 UTC elParaguayo wrote:
> Well, it's almost working but there does seem to be a slight bug which
> doesn't make sense to me. I'll post a question on the GitHub issues page to
> see if it can be fixed. I'll also keep checking to see if I'm missing
> something.
>
> On Wed, 25 Nov 2020, 06:29 Joe Yabuki, <[email protected]> wrote:
>
>> I really appreciate your help ElParaguayo!!!
>>
>> Best Regards
>> Kais
>>
>> ------------------------------
>> *From:* [email protected] <[email protected]> on behalf of
>> elParaguayo <[email protected]>
>> *Sent:* Wednesday, November 25, 2020 1:11:22 AM
>> *To:* qtile-dev <[email protected]>
>> *Subject:* Re: [qtile-dev] Number of opened windows?
>>
>> I would think this is possible without a new widget.
>>
>> My approach would be:
>>
>> 1. find the code that lists windows in current group
>> 2. count the windows
>> 3. send text to a basic TextLayout widget
>> 4. add hooks to update text when windows opened or closed
>>
>> 2, 3 and 4 are easy enough. Just looking at #1 now...
>>
>> On Tuesday, 24 November 2020 at 23:51:04 UTC [email protected] wrote:
>>
>> Thank you for the reply Justine, but I'm looking for a widget to do that!
>>
>> On Tuesday, November 24, 2020 at 5:40:18 p.m. UTC-5 Justine Smithies
>> wrote:
>>
>> I just use the TaskList widget but you could easily make a new widget
>> that just displays the number of open windows.
>>
>> On Tue, 24 Nov 2020, 21:31 Joe Yabuki, <[email protected]> wrote:
>>
>> Hello guys
>> I'm wondering how can there any way to display the number of opened
>> window on the bar. I use the stack layout quite a lot and sometimes I open
>> more than 2 windows and I need to know if the total number of the opened
>> windows!
>>
>> Thank you in advance
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "qtile-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/qtile-dev/6c923fd5-691d-4f01-8f59-92559d501835n%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/qtile-dev/6c923fd5-691d-4f01-8f59-92559d501835n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "qtile-dev" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/qtile-dev/froEabtHAb4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/qtile-dev/a2a2f123-abe4-484d-8a3b-3d2abaee68a0n%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/qtile-dev/a2a2f123-abe4-484d-8a3b-3d2abaee68a0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "qtile-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>>
> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/qtile-dev/DM6PR06MB54180767F21AABE76808BA7AAEFA0%40DM6PR06MB5418.namprd06.prod.outlook.com
>>
>> <https://groups.google.com/d/msgid/qtile-dev/DM6PR06MB54180767F21AABE76808BA7AAEFA0%40DM6PR06MB5418.namprd06.prod.outlook.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/qtile-dev/af469742-64df-4067-b820-3b651c2a031fn%40googlegroups.com.