Can someone help with a question about the Qtile bar?

I use several GenPollText widgets to display the output of scripts in a top 
bar, like this:

screens = [
    Screen(
        top = bar.Bar([
            widget.GenPollText(
                func                       = qtb_1,
                update_interval            = 1800,
                ),
            widget.GenPollText(
                func                       = qtb_2,
                update_interval            = 600,
                ),
            ...

This works very well, but sometimes I want to update one of the values on 
demand rather than wait for the poll interval (the bash scripts are 
expensive). If I click on the bar widget with the mouse, the script 
triggers and the value updates immediately. I'd like to achieve the same 
thing with a key-press. 

Looking at the GenPollText class, it seems a left click calls button_press 
from InLoopPollText in libqtile.widget.base, which updates the widget 
content.

How can I call button_press or, better still, whatever function actually 
does the widget update, from a Key() in my config? I'm very new to Python 
and I need hand-holding with how to create/call the lazy.lazy function and 
have it index the correct widget.

Any help would be greatly appreciated!

A related question: I played with fake_button_press from the Bar API as a 
way to update the widget from the script itself using qtile-cmd, but I 
couldn't get it to work. Using qshell I tried:

  > cd bar/top
  bar[top] > fake_button_press(0,top,5,5,1)

This should hit button-1 at coords (5,5) from top left of screen offset 0. 
Instead I got:

  Command exception: Traceback (most recent call last):
    File "/usr/lib/python3.8/site-packages/libqtile/command_interface.py", 
line 303, in call
      return SUCCESS, cmd(*args, **kwargs)
    File "/usr/lib/python3.8/site-packages/libqtile/bar.py", line 362, in 
cmd_fake_button_press
      self.handle_ButtonPress(fake)
    File "/usr/lib/python3.8/site-packages/libqtile/bar.py", line 272, in 
handle_ButtonPress
      widget = self.get_widget_in_position(e)
    File "/usr/lib/python3.8/site-packages/libqtile/bar.py", line 264, in 
get_widget_in_position
      if e.event_x < i.offsetx + i.length:
  TypeError: '<' not supported between instances of 'str' and 'int'

Casting with int() just gives 'Invalid command:' 

Using qtile-cmd:
  
$ qtile-cmd -o bar top -f fake_button_press -a 0 top 5 5 1
  error: Sorry cannot run function 'fake_button_press' with arguments ['0', 
'top', '5', '5', '1']

Any idea what I'm doing wrong here?
Thanks.

-- 
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 qtile-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/477e84ac-4bc9-447c-8505-6272b58d7db4o%40googlegroups.com.

Reply via email to