Battery: add option to hide widget if no battery detected

This commit is contained in:
Lemmy
2025-12-23 12:46:38 -05:00
parent 4721650878
commit 5cd84e1ecc
17 changed files with 73 additions and 3 deletions
+4
View File
@@ -55,6 +55,10 @@
"description": "Wählen Sie, wie dieser Wert angezeigt werden soll.",
"label": "Anzeigemodus"
},
"hide-if-not-detected": {
"description": "Verberge das Widget, wenn keine Batterie im System erkannt wird.",
"label": "Verstecken, wenn nicht entdeckt."
},
"low-battery-threshold": {
"description": "Warnung anzeigen, wenn Batterie unter diesen Prozentsatz fällt.",
"label": "Schwellenwert für niedrigen Batteriestand"
+4
View File
@@ -55,6 +55,10 @@
"description": "Choose how you'd like this value to appear.",
"label": "Display mode"
},
"hide-if-not-detected": {
"description": "Hide the widget when no battery is detected on the system.",
"label": "Hide if not detected"
},
"low-battery-threshold": {
"description": "Show a warning when battery falls below this percentage.",
"label": "Low battery warning threshold"
+4
View File
@@ -55,6 +55,10 @@
"description": "Elige cómo te gustaría que apareciera este valor.",
"label": "Modo de visualización"
},
"hide-if-not-detected": {
"description": "Ocultar el widget cuando no se detecte batería en el sistema.",
"label": "Ocultar si no se detecta"
},
"low-battery-threshold": {
"description": "Muestra una advertencia cuando la batería cae por debajo de este porcentaje.",
"label": "Umbral de advertencia de batería baja"
+4
View File
@@ -55,6 +55,10 @@
"description": "Choisissez comment vous souhaitez que cette valeur apparaisse.",
"label": "Mode d'affichage"
},
"hide-if-not-detected": {
"description": "Masquer le widget lorsqu'aucune batterie n'est détectée sur le système.",
"label": "Se cacher si non détecté."
},
"low-battery-threshold": {
"description": "Afficher un avertissement lorsque la batterie tombe en dessous de ce pourcentage.",
"label": "Seuil d'avertissement de batterie faible"
+4
View File
@@ -55,6 +55,10 @@
"description": "Válassza ki, hogyan szeretné, hogy ez az érték megjelenjen.",
"label": "Megjelenítési mód"
},
"hide-if-not-detected": {
"description": "Rejtse el a widgetet, ha a rendszer nem észlel akkumulátort.",
"label": "Rejtőzz, ha nem észleltek."
},
"low-battery-threshold": {
"description": "Figyelmeztetés megjelenítése, ha az akkumulátor töltöttsége e százalék alá esik.",
"label": "Alacsony akkumulátor töltöttségi figyelmeztetési küszöb"
+4
View File
@@ -55,6 +55,10 @@
"description": "値の表示方法を選択します。",
"label": "表示モード"
},
"hide-if-not-detected": {
"description": "システムでバッテリーが検出されない場合は、ウィジェットを非表示にします。",
"label": "検出されなければ隠れる"
},
"low-battery-threshold": {
"description": "バッテリー残量がこのパーセンテージを下回ると警告を表示します。",
"label": "低バッテリー警告の閾値"
+4
View File
@@ -55,6 +55,10 @@
"description": "Kies hoe je wilt dat deze waarde wordt weergegeven.",
"label": "Weergavemodus"
},
"hide-if-not-detected": {
"description": "Verberg de widget als er geen batterij op het systeem wordt gedetecteerd.",
"label": "Verbergen indien niet gedetecteerd."
},
"low-battery-threshold": {
"description": "Toon een waarschuwing wanneer de batterij onder dit percentage komt.",
"label": "Waarschuwingsdrempel voor lage batterij"
+4
View File
@@ -55,6 +55,10 @@
"description": "Escolha como você gostaria que este valor aparecesse.",
"label": "Modo de exibição"
},
"hide-if-not-detected": {
"description": "Oculte o widget quando nenhuma bateria for detectada no sistema.",
"label": "Ocultar se não detectado."
},
"low-battery-threshold": {
"description": "Mostrar um aviso quando a bateria cair abaixo desta porcentagem.",
"label": "Limite de aviso de bateria fraca"
+4
View File
@@ -55,6 +55,10 @@
"description": "Выберите, как это значение должно отображаться.",
"label": "Режим отображения"
},
"hide-if-not-detected": {
"description": "Скрыть виджет, если в системе не обнаружена батарея.",
"label": "Скрыться, если не обнаружен."
},
"low-battery-threshold": {
"description": "Показывать предупреждение, когда уровень заряда батареи падает ниже этого процента.",
"label": "Порог предупреждения о низком заряде батареи"
+4
View File
@@ -55,6 +55,10 @@
"description": "Bu değerin nasıl görünmesini istediğinizi seçin.",
"label": "Görüntüleme modu"
},
"hide-if-not-detected": {
"description": "Sistemde pil algılanmadığında araç çubuğunu gizle.",
"label": "Algılanmazsa gizle"
},
"low-battery-threshold": {
"description": "Batarya bu yüzdeye düştüğünde uyarı göster.",
"label": "Düşük batarya eşiği"
+4
View File
@@ -55,6 +55,10 @@
"description": "Виберіть, як ви хочете, щоб це значення відображалося.",
"label": "Режим відображення"
},
"hide-if-not-detected": {
"description": "Приховати віджет, коли в системі не виявлено акумулятор.",
"label": "Приховати, якщо не виявлено"
},
"low-battery-threshold": {
"description": "Показувати попередження, коли батарея падає нижче цього відсотка.",
"label": "Поріг попередження про низький заряд батареї"
+4
View File
@@ -55,6 +55,10 @@
"description": "选择您希望此值显示的方式。",
"label": "显示模式"
},
"hide-if-not-detected": {
"description": "当系统未检测到电池时,隐藏该小部件。",
"label": "如果未被发现,则隐藏。"
},
"low-battery-threshold": {
"description": "当电量低于此百分比时显示警告。",
"label": "低电量警告阈值"
+1
View File
@@ -400,6 +400,7 @@
"hyprland": false,
"mango": false,
"zed": false,
"helix": false,
"enableUserTemplates": false
},
"nightLight": {
+12 -1
View File
@@ -35,9 +35,15 @@ Item {
readonly property bool isBarVertical: Settings.data.bar.position === "left" || Settings.data.bar.position === "right"
readonly property string displayMode: widgetSettings.displayMode !== undefined ? widgetSettings.displayMode : widgetMetadata.displayMode
readonly property real warningThreshold: widgetSettings.warningThreshold !== undefined ? widgetSettings.warningThreshold : widgetMetadata.warningThreshold
readonly property bool hideIfNotDetected: widgetSettings.hideIfNotDetected !== undefined ? widgetSettings.hideIfNotDetected : widgetMetadata.hideIfNotDetected
// Only show low battery warning if device is ready (prevents false positive during initialization)
readonly property bool isLowBattery: isReady && !charging && percent <= warningThreshold
// Visibility: show if hideIfNotDetected is false, or if battery is ready (after initialization)
readonly property bool shouldShow: !hideIfNotDetected || isReady
visible: shouldShow
opacity: shouldShow ? 1.0 : 0.0
// Test mode
readonly property bool testMode: false
readonly property int testPercent: 35
@@ -106,7 +112,12 @@ Item {
return false;
}
if (battery) {
return (battery.type === UPowerDeviceType.Battery && battery.isPresent !== undefined) ? battery.isPresent : (battery.ready && battery.percentage !== undefined);
// For default device, check isPresent if it's a Battery type, otherwise require percentage > 0
if (battery.type === UPowerDeviceType.Battery && battery.isPresent !== undefined) {
return battery.isPresent;
}
// For non-battery types or when isPresent is undefined, require actual percentage
return battery.ready && battery.percentage !== undefined && battery.percentage > 0;
}
return false;
}
@@ -19,6 +19,7 @@ ColumnLayout {
property string valueDeviceNativePath: widgetData.deviceNativePath !== undefined ? widgetData.deviceNativePath : ""
property bool valueShowPowerProfiles: widgetData.showPowerProfiles !== undefined ? widgetData.showPowerProfiles : widgetMetadata.showPowerProfiles
property bool valueShowNoctaliaPerformance: widgetData.showNoctaliaPerformance !== undefined ? widgetData.showNoctaliaPerformance : widgetMetadata.showNoctaliaPerformance
property bool valueHideIfNotDetected: widgetData.hideIfNotDetected !== undefined ? widgetData.hideIfNotDetected : widgetMetadata.hideIfNotDetected
// Build model of available battery devices
function buildDeviceModel() {
@@ -84,6 +85,7 @@ ColumnLayout {
settings.warningThreshold = valueWarningThreshold;
settings.showPowerProfiles = valueShowPowerProfiles;
settings.showNoctaliaPerformance = valueShowNoctaliaPerformance;
settings.hideIfNotDetected = valueHideIfNotDetected;
if (valueDeviceNativePath && valueDeviceNativePath !== "") {
settings.deviceNativePath = valueDeviceNativePath;
} else {
@@ -168,4 +170,11 @@ ColumnLayout {
checked: valueShowNoctaliaPerformance
onToggled: checked => valueShowNoctaliaPerformance = checked
}
NToggle {
label: I18n.tr("bar.widget-settings.battery.hide-if-not-detected.label")
description: I18n.tr("bar.widget-settings.battery.hide-if-not-detected.description")
checked: root.valueHideIfNotDetected
onToggled: checked => root.valueHideIfNotDetected = checked
}
}
+1 -1
View File
@@ -223,7 +223,7 @@ Singleton {
{
"path": "~/.config/helix/themes/noctalia.toml"
}
],
]
},
{
"id": "spicetify",
+2 -1
View File
@@ -91,7 +91,8 @@ Singleton {
"warningThreshold": 30,
"deviceNativePath": "",
"showPowerProfiles": false,
"showNoctaliaPerformance": false
"showNoctaliaPerformance": false,
"hideIfNotDetected": true
},
"Bluetooth": {
"allowUserSettings": true,