feat(ui): show default device name under System Default option

Adds a help text showing which device is the current system default.
This helps users understand what "System Default" will actually use.

Backend:
- New command `get_default_device_name` that uses pactl for PipeWire/Pulse
  and CPAL for ALSA to get the current default device

Frontend:
- Shows "(System Default is: <device name>)" under the output device setting
- Styled as secondary description text (italic, muted)

Translations added for en, es, de, fr.
This commit is contained in:
vicrodh committed 2026-02-13 12:35:56 -06:00
1 parent d3fec83aa2
commit 333e6f224a
8 files changed
+396 -278

No files matched your search

+282 -278
View File
File diff suppressed because it is too large. Load diff
+87
View File
@@ -110,6 +110,93 @@ pub fn check_alsa_utils_installed() -> bool {
true
}
/// Get the name/description of the current default audio device for a backend
#[tauri::command]
pub fn get_default_device_name(backend_type: AudioBackendType) -> Option<String> {
use std::process::Command;
match backend_type {
AudioBackendType::PipeWire | AudioBackendType::Pulse => {
// Use pactl to get default sink description
let output = Command::new("pactl")
.args(["get-default-sink"])
.output()
.ok()?;
if !output.status.success() {
return None;
}
let sink_name = String::from_utf8_lossy(&output.stdout).trim().to_string();
if sink_name.is_empty() {
return None;
}
// Now get the description for this sink
let list_output = Command::new("pactl")
.args(["list", "sinks", "short"])
.output()
.ok()?;
// If we can't get description, return the sink name itself
if !list_output.status.success() {
return Some(sink_name);
}
// Try to get a nicer description from pactl list sinks
let full_list = Command::new("pactl")
.args(["list", "sinks"])
.output()
.ok()?;
if full_list.status.success() {
let stdout = String::from_utf8_lossy(&full_list.stdout);
let mut in_target = false;
for line in stdout.lines() {
if line.contains("Name:") && line.contains(&sink_name) {
in_target = true;
}
if in_target && line.trim().starts_with("Description:") {
return line.trim()
.strip_prefix("Description:")
.map(|s| s.trim().to_string());
}
if in_target && line.starts_with("Sink #") {
break; // Moved to next sink
}
}
}
Some(sink_name)
}
AudioBackendType::Alsa => {
// For ALSA, read from /proc/asound to find which card is default
// The "default" ALSA device typically follows PipeWire/Pulse default
// So we can reuse the PipeWire logic, or read ALSA config
// Simple approach: use CPAL to get default device name
use rodio::cpal::traits::HostTrait;
let available_hosts = rodio::cpal::available_hosts();
let alsa_host_id = available_hosts.into_iter().find(|h| h.name() == "ALSA")?;
let host = rodio::cpal::host_from_id(alsa_host_id).ok()?;
let default_device = host.default_output_device()?;
use rodio::cpal::traits::DeviceTrait;
let device_name = default_device.name().ok()?;
// If it's just "default", try to resolve what it actually points to
if device_name == "default" {
// Fall back to PipeWire/Pulse default since ALSA often uses that
return get_default_device_name(AudioBackendType::PipeWire);
}
Some(device_name)
}
}
}
/// Linux distribution info for install commands
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LinuxDistroInfo {
+1
View File
@@ -855,6 +855,7 @@ pub fn run() {
commands::check_alsa_utils_installed,
commands::get_linux_distro,
commands::query_dac_capabilities,
commands::get_default_device_name,
// Download settings commands
config::download_settings::get_download_settings,
config::download_settings::set_download_root,
@@ -515,6 +515,7 @@
let backendDevices = $state<AudioDevice[]>([]);
let alsaPlugins = $state<AlsaPluginInfo[]>([]);
let isLoadingDevices = $state(false);
let defaultDeviceName = $state<string | null>(null);
// Backend selector options (derived)
// TEST: Re-enable ALSA Direct to verify if CPAL can actually open hw: devices
@@ -2027,9 +2028,18 @@
const devices = await invoke<AudioDevice[]>('get_devices_for_backend', { backendType });
backendDevices = devices;
console.log(`[Audio] Devices for ${backendType}:`, devices);
// Fetch the name of the current default device for this backend
try {
const name = await invoke<string | null>('get_default_device_name', { backendType });
defaultDeviceName = name;
} catch {
defaultDeviceName = null;
}
} catch (err) {
console.error(`Failed to load devices for ${backendType}:`, err);
backendDevices = [];
defaultDeviceName = null;
} finally {
isLoadingDevices = false;
}
@@ -2973,6 +2983,11 @@
<div class="setting-info">
<span class="setting-label">{$t('settings.audio.outputDevice')}</span>
<span class="setting-desc">{$t('settings.audio.outputDeviceDesc')}</span>
{#if defaultDeviceName}
<span class="setting-desc-secondary">
{$t('settings.audio.systemDefaultIs', { values: { device: defaultDeviceName } })}
</span>
{/if}
</div>
{#if isLoadingDevices}
<span class="loading-text">{$t('settings.audio.loadingDevices')}</span>
@@ -5020,6 +5035,13 @@ flatpak override --user --filesystem=/home/USUARIO/Música com.blitzfc.qbz</pre>
color: var(--text-muted);
}
.setting-desc-secondary {
font-size: 11px;
color: var(--text-muted);
opacity: 0.7;
font-style: italic;
}
.setting-note {
font-size: 11px;
color: var(--text-muted);
+1
View File
@@ -530,6 +530,7 @@
"qualityChangedCacheCleared": "Qualität geändert. Wiedergabe-Cache geleert.",
"outputDevice": "Ausgabegerät",
"outputDeviceDesc": "Wählen Sie Ihr bevorzugtes Audioausgabegerät. Angezeigte Geräte stammen aus dem ausgewählten Backend.",
"systemDefaultIs": "System-Standard ist: {device}",
"audioDevice": "Audio-Gerät",
"audioDeviceDesc": "Wählen Sie Ihr bevorzugtes Audioausgabegerät. Angezeigte Geräte stammen aus dem ausgewählten Backend.",
"exclusiveMode": "Exklusivmodus",
+1
View File
@@ -540,6 +540,7 @@
"qualityChangedCacheCleared": "Quality changed. Playback cache cleared.",
"outputDevice": "Output Device",
"outputDeviceDesc": "Select your preferred audio output device. Devices shown are from the selected backend.",
"systemDefaultIs": "System Default is: {device}",
"audioDevice": "Audio Device",
"audioDeviceDesc": "Select your preferred audio output device. Devices shown are from the selected backend.",
"exclusiveMode": "Exclusive Mode",
+1
View File
@@ -540,6 +540,7 @@
"qualityChangedCacheCleared": "Calidad cambiada. Caché de reproducción limpiado.",
"outputDevice": "Dispositivo de Salida",
"outputDeviceDesc": "Selecciona tu dispositivo de audio preferido. Se muestran los dispositivos del backend seleccionado.",
"systemDefaultIs": "Sistema Default es: {device}",
"audioDevice": "Dispositivo de Audio",
"audioDeviceDesc": "Selecciona tu dispositivo de salida de audio preferido. Los dispositivos mostrados son del backend seleccionado.",
"exclusiveMode": "Modo Exclusivo",
+1
View File
@@ -530,6 +530,7 @@
"qualityChangedCacheCleared": "Qualité modifiée. Cache de lecture effacé.",
"outputDevice": "Périphérique de sortie",
"outputDeviceDesc": "Sélectionnez votre périphérique de sortie audio préféré. Les périphériques affichés proviennent du backend sélectionné.",
"systemDefaultIs": "Périphérique par défaut: {device}",
"audioDevice": "Périphérique audio",
"audioDeviceDesc": "Sélectionnez votre périphérique de sortie audio préféré. Les périphériques affichés proviennent du backend sélectionné.",
"exclusiveMode": "Mode exclusif",