If you want you can create two GenPollText widgets with different colors and 
two methods for your bash output. 
Ex. if your bash will return number and lower then 5 you want to have green 
text else blue:

widget.GenPollText(func=commands.get_output_till_5, foreground=GREEN),
widget.GenPollText(func=commands.get_output_from_5, foreground=BLUE),

from subprocess import check_output
def get_output_from_5():
    out = int(check_output(['sh', 
'your_bash.sh']).decode("utf-8").replace('\n', ''))
    if out > 5:
        return out
    return ''

def get_output_till_5():
    out = int(check_output(['sh', 
'your_bash.sh']).decode("utf-8").replace('\n', ''))
    if out <= 5:
        return out
    return ''


On 20/07/15 06:27PM, Patricio Tomas Toledo wrote:
> Reading this forum i found the magic GenPollText. But, is there a way, to 
> change to color depending on the battery level? for example if my func 
> return 5, is there a way to set a color?
> El miércoles, 15 de julio de 2020 a las 22:03:46 UTC-3, Patricio Tomas 
> Toledo escribió:
> 
> > Hi, i'm wondering how to build a custom widget, do you have any example? i 
> > research a lot on the wiki and google, but i didn't found anything. I wanna 
> > build a widget that shows the current battery level of my keyboard and 
> > gamepad.
> >
> > I have my own bash script, and i tried doing a function inside of the 
> > config.py, and using a TextBox widget, but it didn't work. If you have a 
> > short example of how to build my own widget and connected to the config.py 
> > i'll really appreciate. I'm stuck since 2 weeks ago.
> >
> > Pd: Nice work with this is awesome
> >
> 
> -- 
> 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/306a56c6-10d6-43fb-aa4d-2b41a0c49d68n%40googlegroups.com.

-- 
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/20200716040906.wgu3ppad6nfz3nie%40zordmachine.

Reply via email to