pop-os / system76-power

Power profile management for Linux
GNU General Public License v3.0
585 stars 72 forks source link

1.2.0: zbus daemon rewrite & org.freedesktop.UPower.PowerProfiles compat #430

Closed mmstick closed 4 months ago

mmstick commented 5 months ago
mmstick commented 5 months ago

I will log into GNOME and compare the output of dbus to our extension. Did we check if the upower power profiles works for Ubuntu?

jacobgkau commented 5 months ago

On 01a3515, I am not seeing the power profiles exposed in the GUI in Ubuntu, so I don't think they're working.

mmstick commented 5 months ago

@jacobgkau Fixed. com.system76.PowerDaemon had a typo, and the Profiles method was missing for the upower power profiles. Tested with powerprofilesctl

jacobgkau commented 5 months ago

With 9372dc2, the dots do work as expected in the GUI Pop!_OS menu (GNOME Shell extension), and selecting profiles seems to work based on the screen brightness changing. However, the system76-power profile command now lists Power Profile: ? regardless of which power profile is currently active:

Screenshot from 2024-04-30 12-21-43

In addition, I'm still not seeing the options available in the Ubuntu GUI. (Regarding testing with powerprofilesctl, since that command is provided by the power-profiles-daemon package and system76-power still conflicts with that, I'm not sure if you mean it should also work with system76-power or if you just meant comparing the behavior.)

mmstick commented 5 months ago

I manually compiled the latest version of power-profiles-daemon, and used powerprofilesctl with system76-power.

mmstick@Pop-Dev-One:~$ powerprofilesctl get
balanced
mmstick@Pop-Dev-One:~$ powerprofilesctl set performance
mmstick@Pop-Dev-One:~$ powerprofilesctl get
performance
mmstick@Pop-Dev-One:~$ powerprofilesctl list
  power-saver:

* performance:
    Degraded:   no

  balanced:
mmstick commented 5 months ago

The system76-power client should be working again now

mmstick@Pop-Dev-One:~$ system76-power profile
Power Profile: Balanced
Backlight amdgpu_bl1: 25/255 = 9%
Keyboard Backlight asus::kbd_backlight: 0/3 = 0%
mmstick@Pop-Dev-One:~$ system76-power profile performance
mmstick@Pop-Dev-One:~$ system76-power profile
Power Profile: Performance
Backlight amdgpu_bl1: 25/255 = 9%
Keyboard Backlight asus::kbd_backlight: 0/3 = 0%
mmstick@Pop-Dev-One:~$ system76-power graphics
hybrid
mmstick@Pop-Dev-One:~$ system76-power graphics power
on (discrete)
mmstick commented 5 months ago

Installing Ubuntu 24.04 to test compatibility there.

mmstick commented 5 months ago

It would seem that gnome-shell in Ubuntu 24.04 uses the legacy name of the power profiles daemon: net.hadess.PowerProfiles.

jacobgkau commented 5 months ago

In case it's important, on 16cfc5b, I noticed system76-power is failing to start with:

system76-power[3393]: unable to create system service for org.freedesktop.UPower.PowerProfiles

(Not sure if that's just because the name doesn't match net.hadess.PowerProfiles that you referred to.)

jacobgkau commented 5 months ago

The profiles do seem to be working normally again across the CLI and GUI in Pop!_OS now.

mmstick commented 5 months ago

With the added dbus conf, I'm now able to change power profiles in Ubuntu 24.04's power settings page

jacobgkau commented 5 months ago

Confirmed, the Ubuntu GUI is showing up (including in the top-right menu) with ae034d8, and it does work for switching profiles.

I did notice a bug with the top-right menu applet. While I'm able to switch power profiles successfully, the main button of the applet always says "Balanced" and does not reflect the actual active profile. See below:

Screencast from 2024-04-30 14-18-53.webm

If I replace system76-power with power-profiles-daemon, then the applet's preview/button does show the current profile:

Screencast from 2024-04-30 14-22-39.webm

mmstick commented 5 months ago

I'm not sure why gnome-shell is having difficulty here. Need to keep investigating. The power profiles controls in the settings panel is updating fine.

mmstick commented 5 months ago

After extensive debugging, I've come to the conclusion that there is a regression affecting all versions of zbus 4.x.x that breaks property getters in GJS. What's unusual is that property getters work fine everywhere else. If I run busctl --system get-property net.hadess.PowerProfiles /net/hadess/PowerProfiles net.hadess.PowerProfiles ActiveProfile, I get the correct value. I was not able to find any issues when comparing the dbus interface in d-feet with the xml file in gnome-shell. And for whatever reason, property setting works fine from GJS. So it is only property getting that fails with ActiveProfile in GJS.

It's possible the zbus 4.2.0 has a fix, but I was not able to try it out because it's blocked by https://github.com/dbus2/zbus/issues/764

jacobgkau commented 5 months ago

The Ubuntu GUI is now working as expected in both the top-right menu applet and the Power settings page. If I change the profile in either of those places, the other is updated immediately.

I did notice that on Ubuntu, if I change the profile with system76-power profile ..., then the GUI menus are not updated. In Pop!_OS, the gnome-shell-extension-system76-power menu is updated if I use the CLI to change the profile, and that is part of our regression testing checklist. Is there anything that can be done about that on Ubuntu?

I also noticed that in Pop!_OS 22.04, 86130f6 shows two sets of profile menus now (the gnome-shell-extension-system76-power set and the GNOME Shell set):

https://github.com/pop-os/system76-power/assets/7199422/e5f8a280-ff1f-4a73-828f-674f9bcc1c29

The two menus are not kept in sync with one another at all, and changing the profile from the CLI does not change the new GNOME Shell menu. We either need to hide that new menu, or fix the CLI updating and remove the power profiles from the extension menu.

mmstick commented 5 months ago

Looks like we need to patch gnome-shell-extension-system76-power to remove the power profiles from GNOME. I'll check if I'm missing a signal for the power profiles integrations.

jacobgkau commented 5 months ago

On Ubuntu 24.04, the GUI and CLI are now working in conjunction as expected. I can adjust the power profile through the GUI or the CLI, and the GUI always reflects the correct current state. (The top-right drop-down and the Settings app are also kept in sync.)

On Pop!_OS 22.04, the duplicate menu does show up immediately after installing the updates, because GNOME Shell must be restarted to make the updated extension take effect. I don't see how we could get around that (but let me know if there is a way). That's not a serious issue, since the extra menu does partially work (it just isn't kept up-to-date) and goes away with the next restart.

On Pop!_OS 22.04, I do see that the Power Mode section still shows up in Settings after the system76-power update, and the gnome-shell-extension-system76-power menu is not updated if I switch the mode in the Settings app. Can we either fix that (here or in https://github.com/pop-os/gnome-shell-extension-system76-power/pull/94) so the top-right menu gets updated if the Settings app is used to switch the mode, or else patch Settings to prevent that section from showing up after the update?

zeenix commented 4 months ago

It's possible the zbus 4.2.0 has a fix, but I was not able to try it out because it's blocked by dbus2/zbus#764

It did not but now both issues are fixed and I just rolled out zbus 4.2.1 that includes these fixes. I'd strongly recommend switching to zbus 4 as it's the only supported stable version. Thanks for reporting the issues btw.