Ignore battery percentage placeholder if not present in strings

This commit is contained in:
2026-01-14 01:44:33 +01:00
parent e996ad0cc2
commit 7eb7bae9ff
2 changed files with 8 additions and 2 deletions

View File

@@ -258,8 +258,13 @@ func (m *Monitor) check() error {
if newLevel != m.currentLevel && newLevel != "normal" {
log.Printf("Battery level changed to: %s (%d%%)", newLevel, capacity)
var message string
title := level.Title
message := fmt.Sprintf(level.Message, capacity)
if strings.Contains(level.Message, "%d") {
message = fmt.Sprintf(level.Message, capacity)
} else {
message = level.Message
}
// Send notification - it will replace previous one if ID exists
id, err := m.notifier.Send(title, message, "critical", level.Icon)