Skip to content

Commit 15d3861

Browse files
committed
Put indented alerts volume below output volume
1 parent 9c112c6 commit 15d3861

File tree

3 files changed

+48
-58
lines changed

3 files changed

+48
-58
lines changed

cosmic-settings/src/pages/sound/mod.rs

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ impl page::Page<crate::pages::Message> for Page {
120120
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
121121
) -> Option<page::Content> {
122122
Some(vec![
123-
sections.insert(alerts()),
124123
sections.insert(output()),
125124
sections.insert(input()),
126125
sections.insert(device_profiles()),
@@ -345,6 +344,7 @@ fn output() -> Section<crate::pages::Message> {
345344
let mut descriptions = Slab::new();
346345

347346
let volume = descriptions.insert(fl!("sound-output", "volume"));
347+
let alerts_volume = descriptions.insert(format!("\t{}", fl!("sound-alerts", "volume")));
348348
let device = descriptions.insert(fl!("sound-output", "device"));
349349
let _level = descriptions.insert(fl!("sound-output", "level"));
350350
let balance = descriptions.insert(fl!("sound-output", "balance"));
@@ -387,6 +387,35 @@ fn output() -> Section<crate::pages::Message> {
387387
.push(widget::horizontal_space().width(8))
388388
.push(slider);
389389

390+
let alerts_slider = if page.amplification_sink {
391+
widget::slider(0..=150, page.model.notification_volume, |change| {
392+
Message::SetNotificationVolume(change).into()
393+
})
394+
.breakpoints(&[100])
395+
} else {
396+
widget::slider(0..=100, page.model.notification_volume, |change| {
397+
Message::SetNotificationVolume(change).into()
398+
})
399+
};
400+
401+
let alerts_volume_control = widget::row::with_capacity(4)
402+
.align_y(Alignment::Center)
403+
.push(
404+
widget::button::icon(if page.model.notification_mute {
405+
widget::icon::from_name("audio-volume-muted-symbolic")
406+
} else {
407+
widget::icon::from_name("audio-volume-high-symbolic")
408+
})
409+
.on_press(Message::ToggleNotificationMute.into()),
410+
)
411+
.push(
412+
widget::text::body(&page.model.notification_volume_text)
413+
.width(Length::Fixed(22.0))
414+
.align_x(Alignment::Center),
415+
)
416+
.push(widget::horizontal_space().width(8))
417+
.push(alerts_slider);
418+
390419
let devices = widget::dropdown::popup_dropdown(
391420
page.model.sinks(),
392421
Some(page.model.active_sink().unwrap_or(0)),
@@ -404,6 +433,10 @@ fn output() -> Section<crate::pages::Message> {
404433
&*section.descriptions[volume],
405434
volume_control,
406435
))
436+
.add(settings::flex_item(
437+
&*section.descriptions[alerts_volume],
438+
alerts_volume_control,
439+
))
407440
.add(settings::item(&*section.descriptions[device], devices))
408441
.add(settings::item(
409442
&*section.descriptions[balance],
@@ -473,54 +506,6 @@ fn device_profiles() -> Section<crate::pages::Message> {
473506
})
474507
}
475508

476-
fn alerts() -> Section<crate::pages::Message> {
477-
let mut descriptions = Slab::new();
478-
let volume = descriptions.insert(fl!("sound-alerts", "volume"));
479-
let sound = descriptions.insert(fl!("sound-alerts", "sound"));
480-
481-
Section::default()
482-
.title(fl!("sound-alerts"))
483-
.descriptions(descriptions)
484-
.view::<Page>(move |_binder, page, section| {
485-
let slider = if page.amplification_sink {
486-
widget::slider(0..=150, page.model.notification_volume, |change| {
487-
Message::SetNotificationVolume(change).into()
488-
})
489-
.breakpoints(&[100])
490-
} else {
491-
widget::slider(0..=100, page.model.notification_volume, |change| {
492-
Message::SetNotificationVolume(change).into()
493-
})
494-
};
495-
496-
let volume_control = widget::row::with_capacity(4)
497-
.align_y(Alignment::Center)
498-
.push(
499-
widget::button::icon(if page.model.notification_mute {
500-
widget::icon::from_name("audio-volume-muted-symbolic")
501-
} else {
502-
widget::icon::from_name("audio-volume-high-symbolic")
503-
})
504-
.on_press(Message::ToggleNotificationMute.into()),
505-
)
506-
.push(
507-
widget::text::body(&page.model.notification_volume_text)
508-
.width(Length::Fixed(22.0))
509-
.align_x(Alignment::Center),
510-
)
511-
.push(widget::horizontal_space().width(8))
512-
.push(slider);
513-
514-
settings::section()
515-
.title(&section.title)
516-
.add(settings::flex_item(
517-
&*section.descriptions[volume],
518-
volume_control,
519-
))
520-
.into()
521-
})
522-
}
523-
524509
// fn applications() -> Section<crate::pages::Message> {
525510
// let mut descriptions = Slab::new();
526511

cosmic-settings/src/pages/system/info.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ impl Info {
116116
continue;
117117
}
118118
}
119-
119+
120120
// AMD parsing to append codename to specific name
121121
let is_amd_gpu = gpu_name.starts_with("AMD");
122-
122+
123123
if is_amd_gpu {
124124
if adapter_info.device != 0 {
125125
let lspci_gpus = get_lspci_gpu_names();
@@ -404,7 +404,9 @@ fn get_lspci_gpu_names() -> HashMap<u32, String> {
404404
// Extract the GPU name between ": " and the last "["
405405
if let Some(name_start) = line.find(": ") {
406406
let full_name = line[name_start + 2..ids_start].trim();
407-
let gpu_name = full_name.replace(" Corporation", "").replace(" [Intel Graphics]", "");
407+
let gpu_name = full_name
408+
.replace(" Corporation", "")
409+
.replace(" [Intel Graphics]", "");
408410
if !gpu_name.is_empty() {
409411
gpu_map.insert(device_id, gpu_name);
410412
}

crates/cosmic-pipewire/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,9 @@ fn run_service(
383383

384384
"restore.stream.Output/Audio.media.role:Notification" => {
385385
if let Ok(metadata) =
386-
serde_json::de::from_str::<NotificationRouteSettingsMetadata>(
387-
value,
388-
)
386+
serde_json::de::from_str::<
387+
NotificationRouteSettingsMetadata,
388+
>(value)
389389
{
390390
if let Some(state) = state.upgrade() {
391391
let volume = metadata
@@ -394,9 +394,12 @@ fn run_service(
394394
.copied()
395395
.unwrap_or(1.0)
396396
.powf(1.0 / 3.0);
397-
state.borrow_mut().on_event(Event::NotificationVolume(
398-
volume, metadata.mute,
399-
));
397+
state.borrow_mut().on_event(
398+
Event::NotificationVolume(
399+
volume,
400+
metadata.mute,
401+
),
402+
);
400403
}
401404
}
402405
}

0 commit comments

Comments
 (0)