Python sleep in custom status_command
I am trying to write a status command in python, but i'm not sure how to get it to pause for intervals. The sleep function kinda works. The more work that the script does the longer it takes to display. I see in the code for i3 python wrappers a lot of stuff refrencing the i3status process, but i really don't understand what they are doing. However they seem to acomplish what i am trying. I tried with a sleep function in a bash script and it seemed to work much better.
#!/usr/bin/env python
import json
import sys
import time
if __name__ == '__main__':
print('{ "version" : 1 }')
print('[')
print('[],')
while True:
print('[{ "full_text" : "hello world" }],')
#time.sleep(1)
The smaller the time in sleep, the more often the status bare gets updated, however it is not consistent.
here is an example of a custom status_command in python: https://gist.github.com/projectgus/5f...
It works, but i really don't understand what they are trying to do and i haven't been able to add or modify it without breaking something.
As far as I understand they get the output provided by i3status (in the json format, this has to be configured somewhere) and add extra information. See the json format specification at http://i3wm.org/docs/i3bar-protocol.html for more information.
I don't understand why uses the i3status command, and why his infinite loop works where mine doesn't. Does the i3status command control his timing? How would it do that? What you said makes sense though.