After some poking around it seems that the change group hook has a weird 
version of the qtile object that is missing some attributes.
So I've come up with the following solution:
In your config place:
```
from libqtile import qtile  #this is the correct version of the qtile 
object with all attributes
bar_is_hidden = False  #flip this if www is your main group
def toggle_bar(qtile):
    global bar_is_hidden  #I've commited a python nasty here, but 
cmd_hide_show_bar() doesn't store bar state so the config has too
    if qtile.current_group.name == "www" and not bar_is_hidden:
        qtile.cmd_hide_show_bar("top")
        bar_is_hidden = True
    if qtile.current_group.name != "www" and bar_is_hidden:
        qtile.cmd_hide_show_bar("top")
        bar_is_hidden = False
```

Then from your group toggle keybind do something like:
```
Key([mod], "a", lazy.screen.toggle_Group(), lazy.function(toggle_bar), 
desc="toggle group"),
```
note that the keybind wont work with the groups widget. you'll have to bind 
a mouse callback to lazy.function(toggle_bar) if you want to use that.

also if you are using keybinds to switch to specific groups you might have 
to change the logic in the toggle_bar function so that it triggers at the 
appropriate times.

hope this helps. feel free to ask any questions
On Monday, July 19, 2021 at 9:49:19 AM UTC-4 [email protected] wrote:

> I am trying to hide the status bar when the group is "WWW" and unhide the 
> status bar when on any other group. I tried the following code but the 
> qtile log gives an error that says libqtile.qtile is None.
>
> ===========CODE==========
> @hook.subscribe.changegroup
> def toggle_bar():
>     bar = qtile.current_screen.top
>     current_group = qtile.current_group
>     if current_group == "WWW":
>         bar.size = 0
>         bar.window.hide()
>         current_group.layout_all()
>     else:
>         bar.size = 24
>         bar.window.unhide()
>         current_group.layout_all()
> ==========================
>
> ===========ERROR===========
> 2021-07-19 19:10:45,941 ERROR libqtile hook.py:fire():L391 Error in hook 
> changegroup Traceback (most recent call last): File 
> "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 389, in fire 
> i(*args, **kwargs) File "/home/chaitanya/.config/qtile/config.py", line 24, 
> in toggle_bar bar = qtile.current_screen.top AttributeError: 'NoneType' 
> object has no attribute 'top' 
> ==========================
>
> I tried the same thing with with the setgroup hook and I get the a 
> different error.
>
> ===========ERROR===========
> 2021-07-19 19:10:03,735 ERROR libqtile hook.py:fire():L391 Error in hook 
> setgroup
> Traceback (most recent call last):
>   File "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 389, in 
> fire
>     i(*args, **kwargs)
>   File "/home/chaitanya/.config/qtile/config.py", line 32, in toggle_bar
>     bar.window.unhide()
> AttributeError: 'NoneType' object has no attribute 'unhide'
> ==========================
>
>
>

-- 
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/20e6b4ee-aaa3-49dd-a314-1ff3ff73ac21n%40googlegroups.com.

Reply via email to