diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index e191c44..bb112e0 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -57,9 +57,7 @@ Item { // Only notify once we are a below threshold if (!charging && !root.hasNotifiedLowBattery && percent <= warningThreshold) { root.hasNotifiedLowBattery = true - // Maybe go with toast ? - Quickshell.execDetached( - ["notify-send", "-u", "critical", "-i", "battery-caution", "Low Battery", `Battery is at ${p}%. Please connect charger.`]) + ToastService.showWarning("Low Battery", `Battery is at ${Math.round(percent)}%. Please connect the charger.`) } else if (root.hasNotifiedLowBattery && (charging || percent > warningThreshold + 5)) { // Reset when charging starts or when battery recovers 5% above threshold root.hasNotifiedLowBattery = false diff --git a/Modules/SettingsPanel/Bar/WidgetSettings/BatterySettings.qml b/Modules/SettingsPanel/Bar/WidgetSettings/BatterySettings.qml index 54b589a..4e66f65 100644 --- a/Modules/SettingsPanel/Bar/WidgetSettings/BatterySettings.qml +++ b/Modules/SettingsPanel/Bar/WidgetSettings/BatterySettings.qml @@ -16,10 +16,13 @@ ColumnLayout { // Local state property bool valueAlwaysShowPercentage: widgetData.alwaysShowPercentage !== undefined ? widgetData.alwaysShowPercentage : widgetMetadata.alwaysShowPercentage + property int valueWarningThreshold: widgetData.warningThreshold + !== undefined ? widgetData.warningThreshold : widgetMetadata.warningThreshold function saveSettings() { var settings = Object.assign({}, widgetData || {}) settings.alwaysShowPercentage = valueAlwaysShowPercentage + settings.warningThreshold = valueWarningThreshold return settings } @@ -28,4 +31,14 @@ ColumnLayout { checked: root.valueAlwaysShowPercentage onToggled: checked => root.valueAlwaysShowPercentage = checked } + + NSpinBox { + label: "Low battery warning threshold" + description: "Show a warning when battery falls below this percentage." + value: valueWarningThreshold + suffix: "%" + minimum: 5 + maximum: 50 + onValueChanged: valueWarningThreshold = value + } } diff --git a/Widgets/NSpinBox.qml b/Widgets/NSpinBox.qml index a2f2d5c..8e8d630 100644 --- a/Widgets/NSpinBox.qml +++ b/Widgets/NSpinBox.qml @@ -95,7 +95,7 @@ RowLayout { NIcon { anchors.centerIn: parent - text: "dash-lg" + text: "\uF2E6" font.pointSize: Style.fontSizeS * scaling color: decreaseArea.containsMouse ? Color.mOnPrimary : Color.mPrimary } @@ -130,7 +130,7 @@ RowLayout { NIcon { anchors.centerIn: parent - text: "plus-lg" + text: "\uF4FA" font.pointSize: Style.fontSizeS * scaling color: increaseArea.containsMouse ? Color.mOnPrimary : Color.mPrimary }