Skip to content

Commit

Permalink
controller init: set _on_battery before switching profile
Browse files Browse the repository at this point in the history
Since 6ef5b58 , switch_profile expects self._on_battery to be
set, but when it's called in Controller.initialize, it is
called before we do self._on_battery = False , and will crash
with
AttributeError: 'Controller' object has no attribute '_on_battery'
if the requested profile is not the currently active one.

This fixes that by moving the call to switch_profile after
self._on_battery is set.

Signed-off-by: Adam Williamson <[email protected]>
  • Loading branch information
AdamWill committed Aug 15, 2024
1 parent 0a85d3c commit 1831343
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tuned/ppd/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def initialize(self):
self._config = PPDConfig(PPD_CONFIG_FILE)
active_profile = self.active_profile()
self._base_profile = active_profile if active_profile != UNKNOWN_PROFILE else self._config.default_profile
self.switch_profile(self._base_profile)
self._on_battery = False
self.switch_profile(self._base_profile)
if self._config.battery_detection:
self.setup_battery_signaling()

Expand Down

0 comments on commit 1831343

Please sign in to comment.