TheAlexDev23 / power-options

Linux GUI application for blazingly fast and simple power-management.
MIT License
243 stars 1 forks source link

Got rid of a lot of subshell calls #23

Closed ischeinkman closed 2 months ago

ischeinkman commented 2 months ago

Replaced a lot of subshell calls with normal, in-process syscalls.

Specifically:

Implications:

TheAlexDev23 commented 2 months ago

Thanks for your work!

Would you mind moving profile::write_all_cores to the sysfs::writing module that you just created? Feels a bit more suited for that.

Also thanks for highlighting the required uses of subshells too, I will need to research ways of getting rid of those, as creating a shell is technically worse than running an independent Command for commands that do not necessarily require it. The modprobe one shouldn't be hard to do, just multiple synchronous calls to run_command but the lsusb and lspci ones would be harder, either recreating what they do through sysfs or moving the sed code into rust using regex.

ischeinkman commented 2 months ago

Would you mind moving profile::write_all_cores to the sysfs::writing module that you just created? Feels a bit more suited for that.

Yup, done!

Also thanks for highlighting the required uses of subshells too, I will need to research ways of getting rid of those, as creating a shell is technically worse than running an independent Command for commands that do not necessarily require it. The modprobe one shouldn't be hard to do, just multiple synchronous calls to run_command but the lsusb and lspci ones would be harder, either recreating what they do through sysfs or moving the sed code into rust using regex.

Funnily enough the lsusb one will actually be one of the easiest because it seems you've already pulled out the regex parsing code into Rust itself. Really the only difficult one is the lspci call thanks to its sed pipe, but we can use the existing lsusb code as a base to figure that one out.

TheAlexDev23 commented 2 months ago

Thanks.