goloshubov / fnlock-switch-tp-comp-usb-kb

Gnome Shell Extension - FnLk switch for Lenovo ThinkPad Compact USB Keyboard
GNU General Public License v3.0
2 stars 2 forks source link

Use GLib.spawn_command_line_async to spawn the shell that toggles FnLk state #4

Closed crystalcommunication closed 2 weeks ago

crystalcommunication commented 3 months ago

The current code uses GLib.spawn_command_line_sync to spawn the shells that are used to swap the state of the FnLk indicator, but this causes GNOME Shell to freeze up while it waits for the shell to exit. I found that launching it asynchronously still caused the FnLk state to be updated immediately without making the shell freeze for a second sometimes.

goloshubov commented 3 months ago

Good point, thanks. I'll test and update it

goloshubov commented 2 weeks ago

It is async now: Gio.Subprocess.new + communicate_utf8_async.

Probably I'll try to rewrite this without subprocesses at all, by working with fn_lock file directly from the main JS code. Not sure if it'll be faster though. The main problem now is that I have some issues with the symlink to that fn_lock file. I tried to add it in udev rules, but SYMLINK didn't work, and smth like 'ln -f - s' in RUN or PROGRAM gave me the wrong link time to time, it seems like duplicated udev events for some reason, with duplicated devices in the end.