diff --git a/src/dbus/properties.hpp b/src/dbus/properties.hpp index 6feaa43d..5c26a194 100644 --- a/src/dbus/properties.hpp +++ b/src/dbus/properties.hpp @@ -235,6 +235,7 @@ public: void updateAllDirect(); void updateAllViaGetAll(); [[nodiscard]] QString toString() const; + [[nodiscard]] bool isConnected() const { return this->interface; } void pushPropertyUpdate(DBusPropertyCore* property); void requestPropertyUpdate(DBusPropertyCore* property); diff --git a/src/services/upower/powerprofiles.cpp b/src/services/upower/powerprofiles.cpp index b4b477b0..4e9ea926 100644 --- a/src/services/upower/powerprofiles.cpp +++ b/src/services/upower/powerprofiles.cpp @@ -101,6 +101,12 @@ void PowerProfiles::init() { } void PowerProfiles::setProfile(PowerProfile::Enum profile) { + if (!this->properties.isConnected()) { + qCCritical(logPowerProfiles + ) << "Cannot set power profile: power-profiles-daemon not accessible or not running"; + return; + } + if (profile == PowerProfile::Performance && !this->bHasPerformanceProfile) { qCCritical(logPowerProfiles ) << "Cannot request performance profile as it is not present for this device.";