Updating Widget (Clock or Textbox) on specific time

239 views
Skip to first unread message

Frederik Berthelsen

unread,
Oct 14, 2021, 9:36:28 AM10/14/21
to qtile-dev

I tried to create a function which checks what time of day it is. This function simply returns a string depending on time of day.
Now what I want to do is use this function to update the Clock or Textbox widget when a certain time of day is hit, but this means that this function should be called on Clock.update() or similar? Is this possible? I tried using InteractiveCommandClient, but I am pretty sure this is not the way

elParaguayo

unread,
Oct 17, 2021, 4:19:33 AM10/17/21
to qtile-dev
I assume you've got the time checking bits working and you're just asking about updating the widget.

Firstly, updating the Clock is a bit harder as it's got an internal timer which is constantly updating the display. The clock widget has two parameters which may be relevant: "format" which controls the time formatting and "fmt" which is just set to "{}" so it will just display the formatted time. 

Now, to update widgets from inside your config, you can do this:

from libqtile import qtile

clock = qtile.widgets_map["clock"]
# You now have access to the clock widget and all its internals
clock.update("Message here")  # NB this will be overwritten with the next update call from the clock

Same approach can be used for a TextBox

from libqtile import qtile

textbox = qtile.widgets_map["textbox"]  # You can pass the `name` value when initialising widgets in your Bar. The default is the classname in lower case so you'll need to add names if you have more than one textbox.


If you need more help, can you post a discussion on github please. It's impossible to format code nicely in google groups!
Reply all
Reply to author
Forward
0 new messages