MisterGuinness / gnome-shell-extension-sensors

Gnome shell extension: Shows CPU temperature, HDD temperature, voltage and fan RPM
0 stars 0 forks source link

Fedora 39: Make Use of GIO Sub-Processes #95

Closed MisterGuinness closed 5 months ago

MisterGuinness commented 1 year ago

Despite putting effort into getting the "Future" class (contains about 70 lines of code and uses GLib.spawn_async_with_pipes) to properly retrieve stderr I've really wanted to clean up this class.

Also, I want to avoid the double call to "updateDisplay". Every cycle of refreshing the menu requires (depending on preferences chosen) instantiating the "Future" class twice: once to get the output of the sensors command, and again for the hddtemp command. The callback in each case calling "updateDisplay".

Apart from avoiding an unnecessary menu destroy and build, maybe removing the double update will help in the long existing problem with the menu refresh triggering while an item is hovered over (but that, literally, is another issue)

I will follow this guide:

https://gjs.guide/guides/gio/subprocesses.html

with the goal of replacing the "Future" class and applying a consistent approach to sub-processes in

  1. the extension proper where we want to use asynchronous methods for executing commands (to not block gnome-shell), and
  2. the preferences which although running in a separate process (and therefore doesn't block gnome-shell) can still use the asynchronous methods for the extension.
  3. taking a step towards splitting up the utilities module "dumping ground" into discrete parts
  4. see if the async/await pattern can help in making async calls whilst maintaining the feel of synchronous methods. I might name some methods to include an "async" suffix to re-inforce this, although you might claim that calling them via "await" might make that redundant.
  5. use the promise wrapper feature to auto-magically hook in the callback of the "finish" method to the original async GIO method
MisterGuinness commented 6 months ago

Dude, your forgot to add the new subproc js to the makefile, so the make install test I did for F40 didn't copy the file to the install dir