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:
+2
-1
@@ -58,7 +58,8 @@ fn run() -> error::Result<()> {
|
||||
let device = bragi::BragiDevice::open_with_verbose(cli.verbose)?;
|
||||
let level = device.battery_level()?;
|
||||
let status = device.battery_status()?;
|
||||
println!("{}", output::format_waybar_json(level, &status));
|
||||
let sidetone = sidetone::get_level().ok();
|
||||
println!("{}", output::format_waybar_json(level, &status, sidetone));
|
||||
}
|
||||
|
||||
Command::Udev => {
|
||||
|
||||
+7
-2
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user