Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Power] Only show suspend on battery power if the system has a battery #736

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions cosmic-settings/src/pages/power/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ fn power_saving() -> Section<crate::pages::Message> {
let mut descriptions = Slab::new();

let turn_off_screen_desc = descriptions.insert(fl!("power-saving", "turn-off-screen-after"));
let auto_suspend_desc = descriptions.insert(fl!("power-saving", "auto-suspend"));
let auto_suspend_ac_desc = descriptions.insert(fl!("power-saving", "auto-suspend-ac"));
let auto_suspend_battery_desc =
descriptions.insert(fl!("power-saving", "auto-suspend-battery"));
Expand All @@ -397,7 +398,7 @@ fn power_saving() -> Section<crate::pages::Message> {
.idle_conf
.suspend_on_battery_time
.map(|t| Duration::from_millis(t.into()));
settings::section()
let mut section_view = settings::section()
.title(&section.title)
.add(power_saving_row(
&section.descriptions[turn_off_screen_desc],
Expand All @@ -407,19 +408,26 @@ fn power_saving() -> Section<crate::pages::Message> {
Message::ScreenOffTimeChange,
))
.add(power_saving_row(
&section.descriptions[auto_suspend_ac_desc],
&section.descriptions[if page.battery.is_present {
auto_suspend_ac_desc
} else {
auto_suspend_desc
}],
&page.suspend_labels,
suspend_on_ac_time,
SUSPEND_TIMES,
Message::SuspendOnAcTimeChange,
))
.add(power_saving_row(
));
if page.battery.is_present {
section_view = section_view.add(power_saving_row(
&section.descriptions[auto_suspend_battery_desc],
&page.suspend_labels,
suspend_on_battery_time,
SUSPEND_TIMES,
Message::SuspendOnBatteryTimeChange,
))
));
}
section_view
.apply(cosmic::Element::from)
.map(crate::pages::Message::Power)
})
Expand Down
5 changes: 3 additions & 2 deletions i18n/en/cosmic_settings.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,11 @@ power-mode = Power Mode
.performance-desc = Peak performance and power usage.
.no-backend = Backend not found. Install system76-power or power-profiles-daemon.

power-saving = Power Savings Options
power-saving = Power Saving Options
.turn-off-screen-after = Turn off the screen after
.auto-suspend = Automatic suspend
.auto-suspend-ac = Automatic suspend when plugged in
.auto-suspend-battery = Automatic on battery power
.auto-suspend-battery = Automatic suspend on battery power

## Input

Expand Down
Loading