Slowly moving to Codeberg.org
olivierlemoal / i3-swap-focus Goto Github PK
View Code? Open in Web Editor NEWi3/sway script to toggle between last windows
License: MIT License
i3/sway script to toggle between last windows
License: MIT License
Slowly moving to Codeberg.org
Wile executing this code, sometimes I got this error:
Task exception was never retrieved
future: <Task finished coro=<on_signal() done, defined at /home/my-user/bin/i3-swap-focus:15> exception=AttributeError("'NoneType' object has no attribute 'workspace'",)>
Traceback (most recent call last):
File "/home/my-user/bin/i3-swap-focus", line 20, in on_signal
window_workspace = (await i3.get_tree()).find_by_id(window_id).workspace().id
AttributeError: 'NoneType' object has no attribute 'workspace'
My i3wm version is 4.19 running on an Ubuntu 18.04 with three monitors with this configuration:
Monitor 1: workspaces 1, 4 and 6
Monitor 2: workspaces 2 and 5
Monitor 3: workspace 3
On the workspace 5 I have 12 Intellij windows and I was using i3-swap-focus to change mainly between those windows while sometimes interacting with workspace 1 where I have two terminal windows. I'm using the --stay-in-workspace parameter.
Sometimes when I came back from workspace 1 to workspace 2 and try the key combination to call i3-swap-focus the error happens.
Because I am on Ubuntu 18.04, I'm still using it's default Python 3.6.9 so I had to make some adaptations on your original code due to incompatibility with asyncio.create_task
, argparse.BooleanOptionalAction
, asyncio.run
(added just on python 3.7 or 3.8):
#loop.add_signal_handler(signal.SIGUSR1, lambda: asyncio.create_task(on_signal(i3)))
loop.add_signal_handler(signal.SIGUSR1, lambda: loop.create_task(on_signal(i3)))
#parser.add_argument('--stay-in-workspace', action=argparse.BooleanOptionalAction, default=False, help="Do not switch focus if window is on a different workspace")
parser.add_argument('--stay-in-workspace', default=False, help="Do not switch focus if window is on a different workspace")
stay_in_workspace = parser.parse_args().stay_in_workspace
#asyncio.run(main())
main_loop = asyncio.get_event_loop()
main_loop.run_until_complete(main())
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.