diff options
author | Allan Day <allanpday@gmail.com> | 2022-11-24 13:45:33 +0000 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2023-02-07 14:14:45 +0100 |
commit | daaa85d69757a62f99d0730715490a0daf31b231 (patch) | |
tree | fdd659a9b448743b2b38b12756113754d05aac75 /plugins | |
parent | 39d033207a9fc539f06c4fc61add800d0828dce9 (diff) | |
download | gnome-settings-daemon-daaa85d69757a62f99d0730715490a0daf31b231.tar.gz |
power: Change low power notification text
Improve the low power notification text, to reduce ambiguity and
desensitization:
* Deduplicate the headings for critical and action levels
* Remove the time estimate which is often wrong
* Remove ambiguous time periods where possible
This is a partial fix for #686
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/power/gsd-power-manager.c | 84 | ||||
-rwxr-xr-x | plugins/power/test.py | 4 |
2 files changed, 26 insertions, 62 deletions
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c index 757986e3..7832898f 100644 --- a/plugins/power/gsd-power-manager.c +++ b/plugins/power/gsd-power-manager.c @@ -777,19 +777,15 @@ engine_charge_low (GsdPowerManager *manager, UpDevice *device) { const gchar *title = NULL; gchar *message = NULL; - gchar *tmp; - gchar *remaining_text; gdouble percentage; guint battery_level; char *icon_name; - gint64 time_to_empty; UpDeviceKind kind; /* get device properties */ g_object_get (device, "kind", &kind, "percentage", &percentage, - "time-to-empty", &time_to_empty, "battery-level", &battery_level, "icon-name", &icon_name, NULL); @@ -798,27 +794,17 @@ engine_charge_low (GsdPowerManager *manager, UpDevice *device) battery_level = UP_DEVICE_LEVEL_NONE; if (kind == UP_DEVICE_KIND_BATTERY) { - /* TRANSLATORS: notification title, the battery of this laptop/tablet/phone is running low, shows time remaining */ - title = _("Battery low"); - tmp = gpm_get_timestring (time_to_empty); - remaining_text = g_strconcat ("<b>", tmp, "</b>", NULL); - g_free (tmp); - - /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is running low, shows time remaining */ - message = g_strdup_printf (_("Approximately %s remaining (%.0f%%)"), remaining_text, percentage); - g_free (remaining_text); + /* TRANSLATORS: notification title, the battery of this laptop/tablet/phone is running low, shows percentage remaining */ + title = _("Low Battery"); + /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is running low, shows percentage remaining */ + message = g_strdup_printf (_("%.0f%% battery remaining"), percentage); } else if (kind == UP_DEVICE_KIND_UPS) { - /* TRANSLATORS: notification title, an Uninterruptible Power Supply (UPS) is running low, shows time remaining */ - title = _("UPS low"); - tmp = gpm_get_timestring (time_to_empty); - remaining_text = g_strconcat ("<b>", tmp, "</b>", NULL); - g_free (tmp); - - /* TRANSLATORS: notification body, an Uninterruptible Power Supply (UPS) is running low, shows time remaining */ - message = g_strdup_printf (_("Approximately %s of remaining UPS backup power (%.0f%%)"), - remaining_text, percentage); - g_free (remaining_text); + /* TRANSLATORS: notification title, an Uninterruptible Power Supply (UPS) is running low, shows percentage remaining */ + title = _("UPS Low"); + + /* TRANSLATORS: notification body, an Uninterruptible Power Supply (UPS) is running low, shows percentage remaining */ + message = g_strdup_printf (_("%.0f%% UPS power remaining"), percentage); } else { guint i; @@ -869,7 +855,6 @@ engine_charge_critical (GsdPowerManager *manager, UpDevice *device) gdouble percentage; guint battery_level; char *icon_name; - gint64 time_to_empty; GsdPowerActionType policy; UpDeviceKind kind; @@ -878,7 +863,6 @@ engine_charge_critical (GsdPowerManager *manager, UpDevice *device) "kind", &kind, "percentage", &percentage, "battery-level", &battery_level, - "time-to-empty", &time_to_empty, "icon-name", &icon_name, NULL); @@ -886,34 +870,20 @@ engine_charge_critical (GsdPowerManager *manager, UpDevice *device) battery_level = UP_DEVICE_LEVEL_NONE; if (kind == UP_DEVICE_KIND_BATTERY) { - /* TRANSLATORS: notification title, the battery of this laptop/tablet/phone is critically low, warning about action happening soon */ - title = _("Battery critically low"); + /* TRANSLATORS: notification title, the battery of this laptop/tablet/phone is critically low, advice on what the user should do */ + title = _("Battery Almost Empty"); /* we have to do different warnings depending on the policy */ policy = manager_critical_action_get (manager); - if (policy == GSD_POWER_ACTION_HIBERNATE) { - /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is critically low, warning about action happening soon */ - message = g_strdup_printf (_("Hibernating soon unless plugged in.")); - } else if (policy == GSD_POWER_ACTION_SHUTDOWN) { - message = g_strdup_printf (_("Shutting down soon unless plugged in.")); - } - + /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is critically running low, advice on what the user should do */ + message = g_strdup_printf (_("Connect power now")); } else if (kind == UP_DEVICE_KIND_UPS) { - gchar *remaining_text; - gchar *tmp; - /* TRANSLATORS: notification title, an Uninterruptible Power Supply (UPS) is running low, warning about action happening soon */ - title = _("UPS critically low"); - tmp = gpm_get_timestring (time_to_empty); - remaining_text = g_strconcat ("<b>", tmp, "</b>", NULL); - g_free (tmp); + title = _("UPS Almost Empty"); /* TRANSLATORS: notification body, an Uninterruptible Power Supply (UPS) is running low, warning about action happening soon */ - message = g_strdup_printf (_("Approximately %s of remaining UPS power (%.0f%%). " - "Restore AC power to your computer to avoid losing data."), - remaining_text, percentage); - g_free (remaining_text); + message = g_strdup_printf (_("%.0f%% UPS power remaining"), percentage); } else { guint i; @@ -983,19 +953,16 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device) if (kind == UP_DEVICE_KIND_BATTERY) { /* TRANSLATORS: notification title, the battery of this laptop/tablet/phone is critically low, warning about action happening now */ - title = _("Battery critically low"); + title = _("Battery is Empty"); /* we have to do different warnings depending on the policy */ policy = manager_critical_action_get (manager); if (policy == GSD_POWER_ACTION_HIBERNATE) { - /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is critically low, warning about action happening now */ - message = g_strdup (_("The battery is below the critical level and " - "this computer is about to hibernate.")); - + /* TRANSLATORS: notification body, the battery of this laptop/tablet/phone is critically low, warning about action about to happen */ + message = g_strdup (_("This device is about to hibernate")); } else if (policy == GSD_POWER_ACTION_SHUTDOWN) { - message = g_strdup (_("The battery is below the critical level and " - "this computer is about to shutdown.")); + message = g_strdup (_("This device is about to shutdown")); } /* wait 20 seconds for user-panic */ @@ -1005,20 +972,17 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device) g_source_set_name_by_id (timer_id, "[GsdPowerManager] battery critical-action"); } else if (kind == UP_DEVICE_KIND_UPS) { - /* TRANSLATORS: notification title, an Uninterruptible Power Supply (UPS) is running low, warning about action happening now */ - title = _("UPS critically low"); + /* TRANSLATORS: notification title, an Uninterruptible Power Supply (UPS) is critically low, warning about action about to happen */ + title = _("UPS is Empty"); /* we have to do different warnings depending on the policy */ policy = manager_critical_action_get (manager); if (policy == GSD_POWER_ACTION_HIBERNATE) { - /* TRANSLATORS: notification body, an Uninterruptible Power Supply (UPS) is running low, warning about action happening now */ - message = g_strdup (_("UPS is below the critical level and " - "this computer is about to hibernate.")); - + /* TRANSLATORS: notification body, an Uninterruptible Power Supply (UPS) is critically low, warning about action about to happen */ + message = g_strdup (_("This device is about to hibernate")); } else if (policy == GSD_POWER_ACTION_SHUTDOWN) { - message = g_strdup (_("UPS is below the critical level and " - "this computer is about to shutdown.")); + message = g_strdup (_("This device is about to shutdown")); } /* wait 20 seconds for user-panic */ diff --git a/plugins/power/test.py b/plugins/power/test.py index beb88b42..296d6287 100755 --- a/plugins/power/test.py +++ b/plugins/power/test.py @@ -783,7 +783,7 @@ class PowerPluginTest6(PowerPluginBase): # Check that it was picked up self.check_plugin_log('EMIT: charge-critical', 2) - self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery critical.*"', timeout=0.5) + self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery [Aa]lmost [Ee]mpty.*"', timeout=0.5) def test_notify_critical_battery_on_start(self): '''action on critical battery on startup''' @@ -793,7 +793,7 @@ class PowerPluginTest6(PowerPluginBase): # Check that it was picked up self.check_plugin_log('EMIT: charge-critical', 2) - self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery critical.*"', timeout=0.5) + self.p_notify_log.check_line_re(b'[0-9.]+ Notify "Power" .* "battery-caution-symbolic" ".*[Bb]attery [Aa]lmost [Ee]mpty.*"', timeout=0.5) def test_notify_device_battery(self): '''critical power level notification for device batteries''' |