feat: show sidetone level in Waybar tooltip

Tooltip now shows "HS80: 42% — Discharging | Sidetone: 10/23" when
the ALSA sidetone control is available. Falls back gracefully to
battery-only tooltip when sidetone cannot be read.

Bump version to 0.1.1.
This commit is contained in:
2026-04-09 17:13:41 +02:00
parent 46978af7b8
commit 960bc60b20
4 changed files with 38 additions and 16 deletions
+7 -2
View File
@@ -26,7 +26,7 @@ pub fn format_info(vid: u16, pid: u16, fw_app: u16, fw_build: u16) -> String {
/// Formatiert Waybar-kompatibles JSON.
///
/// Waybar erwartet: {"text": "...", "tooltip": "...", "class": "...", "percentage": N}
pub fn format_waybar_json(level: f32, status: &BatteryStatus) -> String {
pub fn format_waybar_json(level: f32, status: &BatteryStatus, sidetone: Option<i64>) -> String {
let icon = status.icon();
let label = status.label();
let percentage = level.round() as u32;
@@ -41,9 +41,14 @@ pub fn format_waybar_json(level: f32, status: &BatteryStatus) -> String {
BatteryStatus::Unknown(_) => "unknown",
};
let tooltip = match sidetone {
Some(st) => format!("HS80: {percentage}% — {label} | Sidetone: {st}/23"),
None => format!("HS80: {percentage}% — {label}"),
};
let json = serde_json::json!({
"text": format!("{icon} {percentage}%"),
"tooltip": format!("HS80: {percentage}% — {label}"),
"tooltip": tooltip,
"class": class,
"percentage": percentage,
});