feat(audio): respect amplification config
This commit is contained in:
parent
c54bf8e189
commit
5a4f4c2018
3 changed files with 103 additions and 68 deletions
117
Cargo.lock
generated
117
Cargo.lock
generated
|
|
@ -836,9 +836,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.36"
|
||||
version = "1.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5252b3d2648e5eedbc1a6f501e3c795e07025c1e93bbf8bbdd6eef7f447a6d54"
|
||||
checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"jobserver",
|
||||
|
|
@ -1464,7 +1464,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"cosmic-config-derive",
|
||||
|
|
@ -1474,7 +1474,7 @@ dependencies = [
|
|||
"iced_futures",
|
||||
"known-folders",
|
||||
"notify",
|
||||
"ron 0.11.0",
|
||||
"ron",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
|
@ -1485,7 +1485,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
|
|
@ -1591,15 +1591,14 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-settings-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-settings-daemon#ff15f3240f6cf36ea74eacbf55ad805377e88a41"
|
||||
source = "git+https://github.com/pop-os/cosmic-settings-daemon#ee782f454a09310a28abe73653e6c82d06a79855"
|
||||
dependencies = [
|
||||
"cosmic-config",
|
||||
"ron 0.9.0",
|
||||
"ron",
|
||||
"serde",
|
||||
"serde_with",
|
||||
"thiserror 2.0.16",
|
||||
"tracing",
|
||||
"xkbcommon 0.7.0",
|
||||
"xkbcommon 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1662,14 +1661,14 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
"csscolorparser",
|
||||
"dirs 6.0.0",
|
||||
"palette",
|
||||
"ron 0.11.0",
|
||||
"ron",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.16",
|
||||
|
|
@ -2969,9 +2968,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.63"
|
||||
version = "0.1.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
|
||||
checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
|
|
@ -2979,7 +2978,7 @@ dependencies = [
|
|||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core 0.62.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2994,7 +2993,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -3012,7 +3011,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_winit",
|
||||
|
|
@ -3021,7 +3020,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
"bytes",
|
||||
|
|
@ -3045,7 +3044,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -3071,7 +3070,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
"bytemuck",
|
||||
|
|
@ -3093,7 +3092,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -3105,7 +3104,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"cosmic-client-toolkit",
|
||||
|
|
@ -3120,7 +3119,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -3136,7 +3135,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"bitflags 2.9.4",
|
||||
|
|
@ -3167,7 +3166,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3186,7 +3185,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_winit"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3975,7 +3974,7 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#e83e43bf1e38476e79383b299668afa525bad3e9"
|
||||
source = "git+https://github.com/pop-os/libcosmic#b9a00c6e799b80154190f11943bb65c1fc4dc58b"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd 0.12.0",
|
||||
|
|
@ -4008,7 +4007,7 @@ dependencies = [
|
|||
"palette",
|
||||
"raw-window-handle",
|
||||
"rfd",
|
||||
"ron 0.11.0",
|
||||
"ron",
|
||||
"rust-embed",
|
||||
"rustix 1.1.2",
|
||||
"serde",
|
||||
|
|
@ -4207,9 +4206,9 @@ checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
|||
|
||||
[[package]]
|
||||
name = "lyon"
|
||||
version = "1.0.1"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91e7f9cda98b5430809e63ca5197b06c7d191bf7e26dfc467d5a3f0290e2a74f"
|
||||
checksum = "dbcb7d54d54c8937364c9d41902d066656817dce1e03a44e5533afebd1ef4352"
|
||||
dependencies = [
|
||||
"lyon_algorithms",
|
||||
"lyon_tessellation",
|
||||
|
|
@ -4217,9 +4216,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lyon_algorithms"
|
||||
version = "1.0.5"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f13c9be19d257c7d37e70608ed858e8eab4b2afcea2e3c9a622e892acbf43c08"
|
||||
checksum = "f4c0829e28c4f336396f250d850c3987e16ce6db057ffe047ce0dd54aab6b647"
|
||||
dependencies = [
|
||||
"lyon_path",
|
||||
"num-traits",
|
||||
|
|
@ -4227,9 +4226,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lyon_geom"
|
||||
version = "1.0.6"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8af69edc087272df438b3ee436c4bb6d7c04aa8af665cfd398feae627dbd8570"
|
||||
checksum = "ce9333c02ea4517fd31207f126124352ad59975218c114c55dbb8f9d56fd4b45"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"euclid",
|
||||
|
|
@ -4238,9 +4237,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lyon_path"
|
||||
version = "1.0.7"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0047f508cd7a85ad6bad9518f68cce7b1bf6b943fb71f6da0ee3bc1e8cb75f25"
|
||||
checksum = "1aeca86bcfd632a15984ba029b539ffb811e0a70bf55e814ef8b0f54f506fdeb"
|
||||
dependencies = [
|
||||
"lyon_geom",
|
||||
"num-traits",
|
||||
|
|
@ -4248,9 +4247,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lyon_tessellation"
|
||||
version = "1.0.15"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579d42360a4b09846eff2feef28f538696c7d6c7439bfa65874ff3cbe0951b2c"
|
||||
checksum = "f3f586142e1280335b1bc89539f7c97dd80f08fc43e9ab1b74ef0a42b04aa353"
|
||||
dependencies = [
|
||||
"float_next_after",
|
||||
"lyon_path",
|
||||
|
|
@ -5690,19 +5689,6 @@ dependencies = [
|
|||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ron"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63f3aa105dea217ef30d89581b65a4d527a19afc95ef5750be3890e8d3c5b837"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bitflags 2.9.4",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ron"
|
||||
version = "0.11.0"
|
||||
|
|
@ -7483,14 +7469,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.61.2"
|
||||
version = "0.62.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||
checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c"
|
||||
dependencies = [
|
||||
"windows-implement 0.60.0",
|
||||
"windows-interface 0.59.1",
|
||||
"windows-link 0.1.3",
|
||||
"windows-result 0.3.4",
|
||||
"windows-link 0.2.0",
|
||||
"windows-result 0.4.0",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
|
|
@ -7561,20 +7547,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.3.4"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
|
||||
checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f"
|
||||
dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
"windows-link 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
|
||||
checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda"
|
||||
dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
"windows-link 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8066,6 +8052,17 @@ dependencies = [
|
|||
"xkeysym",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xkbcommon"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"memmap2 0.9.8",
|
||||
"xkeysym",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xkbcommon-dl"
|
||||
version = "0.4.2"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,29 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry};
|
||||
use cosmic::cosmic_config::{
|
||||
self, Config, ConfigGet, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const AUDIO_CONFIG: &str = "com.system76.CosmicAudio";
|
||||
const AMPLIFICATION_SINK: &str = "amplification_sink";
|
||||
const AMPLIFICATION_SOURCE: &str = "amplification_source";
|
||||
|
||||
pub fn amplification_sink() -> bool {
|
||||
Config::new(AUDIO_CONFIG, 1)
|
||||
.ok()
|
||||
.and_then(|config| config.get::<bool>(AMPLIFICATION_SINK).ok())
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
pub fn amplification_source() -> bool {
|
||||
Config::new(AUDIO_CONFIG, 1)
|
||||
.ok()
|
||||
.and_then(|config| config.get::<bool>(AMPLIFICATION_SOURCE).ok())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize, CosmicConfigEntry, PartialEq, Eq)]
|
||||
#[version = 1]
|
||||
pub struct AudioAppletConfig {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::sync::LazyLock;
|
|||
use std::time::Duration;
|
||||
|
||||
use crate::{localize::localize, pulse::DeviceInfo};
|
||||
use config::AudioAppletConfig;
|
||||
use config::{AudioAppletConfig, amplification_sink, amplification_source};
|
||||
use cosmic::{
|
||||
Element, Renderer, Task, Theme, app,
|
||||
applet::{
|
||||
|
|
@ -63,9 +63,11 @@ pub struct Audio {
|
|||
output_volume: f64,
|
||||
output_volume_debounce: bool,
|
||||
output_volume_text: String,
|
||||
output_amplification: bool,
|
||||
input_volume: f64,
|
||||
input_volume_debounce: bool,
|
||||
input_volume_text: String,
|
||||
input_amplification: bool,
|
||||
current_output: Option<DeviceInfo>,
|
||||
current_input: Option<DeviceInfo>,
|
||||
outputs: Vec<DeviceInfo>,
|
||||
|
|
@ -338,6 +340,9 @@ impl cosmic::Application for Audio {
|
|||
self.popup.replace(new_id);
|
||||
self.timeline = Timeline::new();
|
||||
|
||||
self.output_amplification = amplification_sink();
|
||||
self.input_amplification = amplification_source();
|
||||
|
||||
let popup_settings = self.core.applet.get_popup_settings(
|
||||
self.core.main_window_id().unwrap(),
|
||||
new_id,
|
||||
|
|
@ -758,6 +763,23 @@ impl cosmic::Application for Audio {
|
|||
.align_x(Alignment::Center)
|
||||
)]
|
||||
} else {
|
||||
let output_slider = if self.output_amplification {
|
||||
slider(0.0..=150.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.])
|
||||
} else {
|
||||
slider(0.0..=100.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
};
|
||||
let input_slider = if self.input_amplification {
|
||||
slider(0.0..=150.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.])
|
||||
} else {
|
||||
slider(0.0..=100.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
};
|
||||
|
||||
column![
|
||||
padded_control(
|
||||
row![
|
||||
|
|
@ -770,9 +792,7 @@ impl cosmic::Application for Audio {
|
|||
.icon_size(24)
|
||||
.line_height(24)
|
||||
.on_press(Message::SetOutputMute(!out_mute)),
|
||||
slider(0.0..=150.0, self.output_volume, Message::SetOutputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.]),
|
||||
output_slider,
|
||||
container(text(&self.output_volume_text).size(16))
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Alignment::End)
|
||||
|
|
@ -791,9 +811,7 @@ impl cosmic::Application for Audio {
|
|||
.icon_size(24)
|
||||
.line_height(24)
|
||||
.on_press(Message::SetInputMute(!in_mute)),
|
||||
slider(0.0..=150.0, self.input_volume, Message::SetInputVolume)
|
||||
.width(Length::FillPortion(5))
|
||||
.breakpoints(&[100.]),
|
||||
input_slider,
|
||||
container(text(&self.input_volume_text).size(16))
|
||||
.width(Length::FillPortion(1))
|
||||
.align_x(Alignment::End)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue