Python sleep in custom status_command

asked 2015-05-07 10:04:46 +0000

TheRoach gravatar image

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 }')

      while True:
           print('[{ "full_text" : "hello world" }],')

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:

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.

edit retag flag offensive close merge delete


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 for more information.

i3convert gravatar imagei3convert ( 2015-05-07 14:04:46 +0000 )edit

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.

TheRoach gravatar imageTheRoach ( 2015-05-07 16:58:37 +0000 )edit