altdesktop/i3ipc-python

Am I using i3-cycle-focus.py correctly? It's quite slow/laggy/buggy.

geoboom opened this issue · 4 comments

Hi, I downloaded the i3-cycle-focus.py, chmod +x it, and copied into /usr/bin/ and /bin/ (I assume to do this because there are no installation instructions anywhere apart from pip3 install i3ipc. Then, I added exec_always --no-startup-id i3-cycle-focus.py --history 2 and bindsym Mod1+Tab exec --no-startup-id i3-cycle-focus.py --switch into my .i3/config, as per the instructions in the python file and restarted i3.

I switched windows a few times and pressed alt+tab (my Mod1=alt) but nothing happened. Relevant output of ps aux | grep i3-cycle-focus is as follows:

geoboom   259847  0.0  0.0 316964 19020 ?        Sl   00:24   0:00 python3 /usr/bin/i3-cycle-focus.py --history 2

so the script is active for sure. It's only after like 20 seconds does the script start taking effect i.e. when I alt+tab I can switch between last used windows. But when I switch to another window/workspace and try alt+tab again, it switches to my first 2 windows rather than the latest 2. I think I might have installed the script wrongly or set it up wrongly... I am not sure. But it definitely is really slow to start up and really buggy as it doesn't switch between my 2 LRU windows but rather the first 2 windows I had focus in. It stops working completely after a few minutes too. Also, I'm not sure what to do with .xsession or .xinitrc as I've already added the exec_always in my i3 config.

Can anyone walk me through the installation please? Thanks.

I haven't tested this script in awhile so it might be buggy. I might go and try to fix it up soon.

I've rewritten the example to use asyncio which should be much more stable. Use the --debug flag to turn on debug logging.

Hi, sorry for the late reply due to vacation. First, thank you for using the script. I hope you'll find it useful once the issues are resolved.

There are a few things to note:

  1. There are no installation instructions for the script itself because it's distributed as an example together with the i3ipc python package. There's the commandline help by the -h option, though.
  2. Note the --delay option with a default of 2 seconds. This means that focus must stay for at least 2 seconds on a window for the window to be added to the top of the focus history "stack". So if a window has focus only for 1 second then it won't be added to the focus history. This is a workaround for the fact that the script can't detect when the Alt key is released (to update the focus history then). Could that be the cause for you that some windows do not end up in the focus history?
  3. In general, the script works fine for me (the previous version before the rewrite). I execute it like that: exec_always i3-cycle-focus --delay 1.5 --ignore-floating --visible-workspaces (with the location of the script being in PATH). Note that I use the default history stack size of 16 windows. I don't have the issue of the script taking too long to start or stop working. That doesn't mean that the script is free of issues, though 😀 Especially when using it differently because then it might not get a lot of testing.
  4. I notice a glitch every now and then (when repeatedly hitting Alt-Tab, sometimes no window is focused for one hit of Tab), but I didn't look into that yet. Of course, I'm open to fix issues, though.

I've rewritten the example to use asyncio which should be much more stable. Use the --debug flag to turn on debug logging.

Thank you for rewriting it and adding the debug option!