UshakovVasilii / gnome-shell-extension-freon

Shows CPU temperature, disk temperature, video card temperature (NVIDIA/Catalyst/Bumblebee&NVIDIA), voltage and fan RPM
https://extensions.gnome.org/extension/841/freon
GNU General Public License v2.0
431 stars 77 forks source link

ask user to install a pkexec policy when running freeipmi with pkexec #273

Closed illwieckz closed 12 months ago

illwieckz commented 12 months ago

A PkexecUtil class is provided to be reused by other tools like smartctl or nvme-cli in the future.

This implements a way to ship a pkexec policy file and to ask the user to install it when missing, once pkexec exec method is selected.

This provides a policy file for ipmi-sensors for now.

For now the /usr/sbin/ prefix for super user binaries is hardcoded, I'm not sure we can generate a policy file on the fly, so maybe there is no good way to not hardcode this.

If setting up pkexec fails (because either pkexec is not found, the super user binary (here /usr/sbin/ipmi-sensors) is not found, or the user did did not gave the right password, the settings is reset to direct to avoid endless password requests).

One known bug is that when the setting is reset on failure, the preferences window do not update, but closing the preference window and reopening it shows the setting is properly reset.

I'm not fluent in javascript so there may be better ways to do it.

I believe it's better to merge this than to wait for something better, because right now the current code in master annoys the user with endless password requests, those password requests taking priority and preventing to reset the option.

Fixes #272:

illwieckz commented 12 months ago

This should be merged first or the code won't work: