Commit graph

221 commits

Author SHA1 Message Date
Vincent Bernat
71a3d1d4a4 i3-companion: move polybar handling into its own function 2021-07-13 08:11:48 +02:00
Vincent Bernat
71dcb5d6bc i3-companion: rename dampen to debounce
I think this is more correct. Dampen is used in network world, but
debounce seems more common (notably, we debounce push buttons).
Another word could be throttle but that does not match as we need to
react to the last event of a batch instead of the first (and we sure
don't want to drop the last).
2021-07-13 00:39:45 +02:00
Vincent Bernat
2781777842 i3-companion: also dampen a bit workspace renames
Just because I want to use this new function!
2021-07-13 00:31:26 +02:00
Vincent Bernat
b6354b1256 i3-companion: move all state inside fn.worker namespace
This is cleaner than putting arbitrary attributes inside a task. The
scheduling will be done later, so it is safe to put put everything
inside the namespace object and avoid polluting the function
namespace.
2021-07-13 00:26:31 +02:00
Vincent Bernat
b62f747837 i3-companion: add back ability to trigger urgent work despite of damping 2021-07-13 00:13:55 +02:00
Vincent Bernat
f56b995d5a i3-companion: rework dampener to be easier to understand
We have a worker running as long as there is work. The optional sleep
is not implemented. There is a slight semantic difference: the work is
not postponed indefinitely.
2021-07-12 23:57:06 +02:00
Vincent Bernat
9b0bb1ce76 i3-companion: fix dampening
Cancellation is asynchronous. So, there was a race condition where we
were throwing away the task we just scheduled. Don't really on
cancellation for synchronization. We also want to have only one
instance running. So, use locks to ensure only one instance is running
and only cancel running functions while in sleeping phase, otherwise,
let them run.

Currently, this OK, however, it is assumed the function has somehow
the same effect whatever the arguments we provide. This is true for
the two callbacks we use `@dampen` on.
2021-07-12 23:37:25 +02:00
Vincent Bernat
2012ba0c15 i3-companion: move dampening/retry logic inside a decorator
There is some nasty bug we can run into:

```
ERROR: Task was destroyed but it is pending!
task: <Task pending name='Task-44' coro=<dampen.<locals>.decorator.<locals>.fn_now() running at /home/bernat/.config/i3/bin/i3-companion:115> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f687353e2b0>()]>>
```

This is often followed by a segfault. It's a bit difficult to
understand where it comes from. Sleeping a bit even if we don't want
to dampen seems to workaround this issue. It seems we have to keep a
reference to a task until it is cancelled properly.
2021-07-12 22:15:57 +02:00
Vincent Bernat
fb0bd7fcca i3-companion: fix logging to console 2021-07-12 21:17:25 +02:00
Vincent Bernat
654d8bd0a1 i3-companion: don't use sticky windows for icon selection 2021-07-12 20:01:49 +02:00
Vincent Bernat
52ba86e239 i3-companion: do not log full network status
With special chars, it's not readable.
2021-07-12 17:56:41 +02:00
Vincent Bernat
55c335bcaa i3-companion: no need to subclass string, just use a function 2021-07-12 15:04:08 +02:00
Vincent Bernat
33e59c769a i3-companion: display notifications for Bluetooth
This is a good example of using PropertiesChanged. I don't know if
it's possible to filter the interface we want to receive.
2021-07-12 13:18:57 +02:00
Vincent Bernat
a30c4a5aa9 i3-companion: fix vpn icon 2021-07-12 12:59:00 +02:00
Vincent Bernat
9b5c00b92a i3-companion: force font to use when using symbols 2021-07-12 12:02:02 +02:00
Vincent Bernat
7669da1c9f i3-companion: move configuration at the top 2021-07-12 10:10:38 +02:00
Vincent Bernat
f2e6173e30 i3-companion: also add a type for events from nop command 2021-07-12 09:11:03 +02:00
Vincent Bernat
f454a74080 i3-companion: rename i3ipc.Event to I3Event 2021-07-12 09:05:17 +02:00
Vincent Bernat
2773dfdedc i3-companion: if SSID is not UTF-8 encoded, use replace 2021-07-12 08:52:26 +02:00
Vincent Bernat
0f2b12e228 i3-companion: handle correctly unconnected polybar sockets
It's the `open()` call which is blocking, not the `write()`. Use
`os.open()` instead.
2021-07-12 08:45:09 +02:00
Vincent Bernat
51fe9fff00 i3-companion: DBus errors are expected on interface down 2021-07-12 08:13:25 +02:00
Vincent Bernat
9fff419b2d i3-companion: remove skip code
Most of the time, we don't skip the update.
2021-07-12 08:11:48 +02:00
Vincent Bernat
f0a7eca578 i3-companion: cosmetic fixes
Also update immediately if active connection change.
2021-07-12 08:11:05 +02:00
Vincent Bernat
7df5011824 i3-companion: replace network module by custom IPC for Network Manager 2021-07-12 07:32:39 +02:00
Vincent Bernat
b3c386b778 i3-companion: rename network_manager_update
The goal is only to display notifications.
2021-07-11 22:52:50 +02:00
Vincent Bernat
d56b44114a i3-companion: ensure variables are captured when wrapping event 2021-07-11 22:46:53 +02:00
Vincent Bernat
83ba6b5a23 i3-companion: also listen to DBus for NetworkManager
As a proof of concept add notifications for events.
2021-07-11 22:06:23 +02:00
Vincent Bernat
674a4eab56 i3-companion: run black with max line length to 79 2021-07-11 20:47:51 +02:00
Vincent Bernat
0e88b0f545 i3-companion: blacken the code 2021-07-11 12:23:00 +02:00
Vincent Bernat
0984436348 i3-companion: move notify helper function at top 2021-07-11 12:20:42 +02:00
Vincent Bernat
f98b530813 i3-companion: use dbussy to interact with DBus
`notify-send` is too limited, notably to get the notification ID.
2021-07-11 12:18:19 +02:00
Vincent Bernat
4f28e682e1 i3-companion: encapsulate state into function object
This avoids littering the code with global variables.
2021-07-11 11:42:23 +02:00
Vincent Bernat
c8af3d585a i3-companion: wait longer to debounce XRandR events 2021-07-11 00:28:11 +02:00
Vincent Bernat
c13fb9f387 i3-companion: use double exec for Quake console as well 2021-07-11 00:26:52 +02:00
Vincent Bernat
6638bfdb36 i3-companion: log to systemd 2021-07-10 13:17:07 +02:00
Vincent Bernat
5583ecdc52 i3-companion: add icon for gitg 2021-07-10 13:07:14 +02:00
Vincent Bernat
a2588342ff i3-companion: fix logic for container layout
Only empty workspaces are special. They follow `workspace_layout`
value, except if `default`, in this case `layout`.
2021-07-09 20:35:59 +02:00
Vincent Bernat
8490fed7bc i3-companion: don't display layout for leaves, it does not make sense
If we change the direction of a window, this creates a new container.
I don't think layout is used at all for windows.
2021-07-09 20:18:53 +02:00
Vincent Bernat
47d4fc848c i3-companion: don't display layout for workspaces unless empty 2021-07-09 20:11:56 +02:00
Vincent Bernat
856ef13c02 i3-companion: display tree for the current workspace
This helps to understand what's happening.
2021-07-09 16:12:00 +02:00
Vincent Bernat
7f17d6f397 i3-companion: only consider instance/class for icon
Name may be too random. Straighten a bit the regex too to avoid
matching on prefixes.
2021-07-08 14:25:14 +02:00
Vincent Bernat
396ca23b33 i3-companion: use Steam icon for Steam 2021-07-08 12:06:42 +02:00
Vincent Bernat
5239148319 i3-companion: use bindings to communicate with companion
This avoids spawning an i3-msg process. The drawback is that we have
to listen to all keybindings.
2021-07-08 12:01:17 +02:00
Vincent Bernat
3909defef4 i3-companion: also display window type on window info 2021-07-07 23:12:57 +02:00
Vincent Bernat
9196497e6c i3-companion: don't move exclusive apps to new workspace when alone 2021-07-07 23:11:22 +02:00
Vincent Bernat
eea648a27a i3-companion: display percent value for window info 2021-07-07 22:04:38 +02:00
Vincent Bernat
b368fb65c5 i3-companion: not all containers have a window ID 2021-07-07 22:03:39 +02:00
Vincent Bernat
d215c151a9 i3-companion: fix some edge cases for exclusive workspaces 2021-07-07 18:52:19 +02:00
Vincent Bernat
46462ebd4a i3-companion: make some workspace exclusives
When they contain some apps, new apps should go to a new workspace,
unless they can intrude.
2021-07-07 17:53:59 +02:00
Vincent Bernat
ed203771f1 i3-companion: add back missing event binding 2021-07-07 16:58:07 +02:00