BatteryService: load toast messages from file

This commit is contained in:
Damian D'Souza
2025-10-10 20:39:44 +02:00
parent c1e9f0e0b3
commit 684f8b3a53
2 changed files with 19 additions and 9 deletions
+10
View File
@@ -1424,6 +1424,16 @@
"low": "Low battery",
"low-desc": "Battery is at {percent}%. Please connect the charger."
},
"battery-manager": {
"title": "Battery threshold",
"set-success-desc": "Battery threshold set to {percent}%",
"initial-setup": "Initial setup required",
"set-failed": "Failed to set battery threshold",
"install-success": "Installed successfully",
"install-missing": "Required files are missing",
"install-unsupported": "System is not supported",
"install-failed": "Installation failed"
},
"missing-control-center": {
"label": "Last Control Center widget removed",
"description": "The Control Center widget has been removed from the bar. To access it from the bar again, you will need to re-add the widget. You can open it with right clicking on the bar too."
+9 -9
View File
@@ -97,15 +97,16 @@ Singleton {
if (exitCode === 0) {
Logger.log("BatteryService", "Battery threshold set successfully")
if (!BatteryService.hideSuccessToast) {
ToastService.showNotice("Battery Manager", `Battery threshold set to ${BatteryService.getThresholdValue(BatteryService.chargingMode)}%`)
ToastService.showNotice(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.set-success-desc", {
"percent": BatteryService.getThresholdValue(BatteryService.chargingMode)
}))
Settings.data.battery.chargingMode = BatteryService.chargingMode
}
} else if (exitCode === 2) {
// Initial setup required - show toast and run installer
ToastService.showWarning("Battery Manager", "Initial setup required")
ToastService.showWarning(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.initial-setup"))
BatteryService.runInstaller()
} else {
ToastService.showError("Battery Manager", "Failed to set battery threshold")
ToastService.showError(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.set-failed"))
Logger.error("BatteryService", `Setter process failed with exit code: ${exitCode}`)
}
}
@@ -132,15 +133,14 @@ Singleton {
running: false
onExited: (exitCode, exitStatus) => {
if (exitCode === 0) {
ToastService.showNotice("Battery Manager", "Installed successfully")
// Installation successful, retry setting the battery threshold
ToastService.showNotice(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.install-success"))
BatteryService.applyChargingMode()
} else if (exitCode === 2) {
ToastService.showError("Battery Manager", "Required files are missing")
ToastService.showError(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.install-missing"))
} else if (exitCode === 3) {
ToastService.showError("Battery Manager", "System is not supported")
ToastService.showError(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.install-unsupported"))
} else {
ToastService.showError("Battery Manager", "Installation failed")
ToastService.showError(I18n.tr("toast.battery-manager.title"), I18n.tr("toast.battery-manager.install-failed"))
}
if (exitCode !== 0) {