fix(region): dont update time settings on set_locale failure
this fixes so that time settings are not changed if failed to authenticate etc.
This commit is contained in:
parent
b0085cac0e
commit
2d66960671
1 changed files with 11 additions and 6 deletions
|
|
@ -235,9 +235,11 @@ impl Page {
|
||||||
let region = region.lang_code.clone();
|
let region = region.lang_code.clone();
|
||||||
|
|
||||||
return cosmic::task::future(async move {
|
return cosmic::task::future(async move {
|
||||||
_ = set_locale(lang, region.clone()).await;
|
if let Ok(exit_status) = set_locale(lang, region.clone()).await {
|
||||||
|
if exit_status.success() {
|
||||||
update_time_settings_after_region_change(region);
|
update_time_settings_after_region_change(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Message::Refresh(Arc::new(page_reload().await))
|
Message::Refresh(Arc::new(page_reload().await))
|
||||||
});
|
});
|
||||||
|
|
@ -882,9 +884,12 @@ fn popover_menu_row(
|
||||||
.map(move |()| Message::SourceContext(message(id)))
|
.map(move |()| Message::SourceContext(message(id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_locale(lang: String, region: String) {
|
pub async fn set_locale(
|
||||||
|
lang: String,
|
||||||
|
region: String,
|
||||||
|
) -> Result<std::process::ExitStatus, std::io::Error> {
|
||||||
eprintln!("setting locale lang={lang}, region={region}");
|
eprintln!("setting locale lang={lang}, region={region}");
|
||||||
_ = tokio::process::Command::new("localectl")
|
tokio::process::Command::new("localectl")
|
||||||
.arg("set-locale")
|
.arg("set-locale")
|
||||||
.args(&[
|
.args(&[
|
||||||
["LANG=", &lang].concat(),
|
["LANG=", &lang].concat(),
|
||||||
|
|
@ -899,7 +904,7 @@ pub async fn set_locale(lang: String, region: String) {
|
||||||
["LC_TIME=", ®ion].concat(),
|
["LC_TIME=", ®ion].concat(),
|
||||||
])
|
])
|
||||||
.status()
|
.status()
|
||||||
.await;
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_locale(locale: &str) -> Option<Locale> {
|
fn parse_locale(locale: &str) -> Option<Locale> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue