chore: update dependencies

The ICU update reduces binary size by ~20 MB.
This commit is contained in:
Vukašin Vojinović 2025-09-16 13:08:16 +02:00 committed by Jeremy Soller
parent f1f7862fbc
commit 31912afaa1
11 changed files with 878 additions and 928 deletions

1582
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,12 +8,8 @@ vergen = { version = "8", features = ["git", "gitcl"] }
[dependencies]
anyhow = "1"
async-fn-stream = "0.2.2"
icu = { version = "1.5.0", features = [
"experimental",
"compiled_data",
"icu_datetime_experimental",
] }
async-fn-stream = "0.3"
icu = { version = "2.0.0", features = ["compiled_data"] }
chrono-tz = "0.10"
chrono = { version = "0.4", features = ["unstable-locales"] }
cosmic-applets-config.workspace = true
@ -41,10 +37,10 @@ pwd.workspace = true
ron.workspace = true
shlex = "1.3.0"
xkb-data = "0.2"
xdg = "2.5.2"
xdg = "3.0"
#TODO: reduce features
tokio = { workspace = true, features = ["full"] }
wayland-client = "0.31.8"
wayland-client = "0.31.11"
cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settings-subscriptions", default-features = false, features = [
"accessibility",
"cosmic_a11y_manager",
@ -52,10 +48,8 @@ cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settin
cosmic-settings-daemon-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", default-features = false, features = [
"greeter",
] }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "178eb0b" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
"client",
], rev = "1425bd4" }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = ["client"] }
# For network status using networkmanager feature
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
@ -70,13 +64,13 @@ zbus = { workspace = true, optional = true }
# CLI arguments
clap_lex = "0.7"
# Internationalization
i18n-embed = { version = "0.14", features = [
i18n-embed = { version = "0.16", features = [
"fluent-system",
"desktop-requester",
] }
i18n-embed-fl = "0.7"
i18n-embed-fl = "0.10"
rust-embed = "8"
futures-util = "0.3.30"
futures-util = "0.3.31"
timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
cosmic-randr-shell = { workspace = true }
kdl.workspace = true
@ -118,11 +112,11 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
color-eyre = "0.6.5"
# Fix zbus compilation by manually adding nix with user feature
nix = { version = "0.29", features = ["user"] }
nix = { version = "0.30", features = ["user"] }
pwd = "1.4.0"
ron = "0.10.1"
ron = "0.11"
serde = "1"
tokio = "1.39.1"
tokio = "1.47.1"
zbus = "5"
kdl = "6"
cosmic-randr-shell = { git = "https://github.com/pop-os/cosmic-randr", default-features = false, branch = "kdl-command" }
@ -155,11 +149,12 @@ default-features = false
git = "https://github.com/pop-os/libcosmic"
default-features = false
[patch."https://github.com/smithay/client-toolkit.git"]
sctk = { package = "smithay-client-toolkit", version = "=0.19.2" }
sctk = { package = "smithay-client-toolkit", version = "0.20.0" }
[patch."https://github.com/pop-os/cosmic-protocols"]
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols//", rev = "5035f8c" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols//" }
cctk = { git = "https://github.com/pop-os/cosmic-protocols//", package = "cosmic-client-toolkit" }
# libcosmic = { path = "../libcosmic" }
# cosmic-config = { path = "../libcosmic/cosmic-config" }

View file

@ -1,7 +1,7 @@
[package]
name = "cosmic-greeter-config"
version = "0.1.0"
edition = "2021"
edition = "2024"
description = "Configuration for COSMIC Greeter"
repository = "https://github.com/pop-os/cosmic-greeter"
license = "GPL-3.0-only"

View file

@ -3,10 +3,9 @@
pub mod user;
use std::{collections::HashMap, num::NonZeroU32};
use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};
use cosmic_config::{CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, num::NonZeroU32};
pub const APP_ID: &str = "com.system76.CosmicGreeter";
pub const CONFIG_VERSION: u64 = 1;

View file

@ -1,9 +1,8 @@
// Copyright 2024 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use std::num::NonZeroU32;
use serde::{Deserialize, Serialize};
use std::num::NonZeroU32;
/// Per user state for Greeter.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]

View file

@ -1,7 +1,7 @@
[package]
name = "cosmic-greeter-daemon"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -26,7 +26,7 @@ kdl.workspace = true
#TODO: reduce features
tokio = { workspace = true, features = ["full"] }
xdg = "3.0.0"
xdg = "3.0"
[features]
default = ["systemd"]

View file

@ -8,7 +8,7 @@ use std::{
};
pub use cosmic_applets_config::time::TimeAppletConfig;
pub use cosmic_bg_config::{state::State as BgState, Color, Source as BgSource};
pub use cosmic_bg_config::{Color, Source as BgSource, state::State as BgState};
pub use cosmic_comp_config::{CosmicCompConfig, XkbConfig, ZoomConfig};
pub use cosmic_theme::{Theme, ThemeBuilder};

View file

@ -1,11 +1,10 @@
use color_eyre::eyre::Context;
use color_eyre::eyre::WrapErr;
use cosmic_greeter_daemon::UserData;
use std::{env, error::Error, future::pending, io, path::Path};
use tracing::metadata::LevelFilter;
use tracing::{error, warn};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use zbus::{connection::Builder, DBusError};
use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
use zbus::{DBusError, connection::Builder};
//IMPORTANT: this function is critical to the security of this proxy. It must ensure that the
// callback is executed with the permissions of the specified user id. A good test is to see if
@ -15,7 +14,9 @@ fn run_as_user<F: FnOnce() -> T, T>(user: &pwd::Passwd, f: F) -> Result<T, io::E
let root_home_opt = env::var_os("HOME");
// Switch to user HOME
env::set_var("HOME", &user.dir);
unsafe {
env::set_var("HOME", &user.dir);
}
// Switch to user UID
if unsafe { libc::seteuid(user.uid) } != 0 {
@ -31,8 +32,12 @@ fn run_as_user<F: FnOnce() -> T, T>(user: &pwd::Passwd, f: F) -> Result<T, io::E
// Restore root HOME
match root_home_opt {
Some(root_home) => env::set_var("HOME", root_home),
None => env::remove_var("HOME"),
Some(root_home) => unsafe {
env::set_var("HOME", root_home);
},
None => unsafe {
env::remove_var("HOME");
},
}
Ok(t)

View file

@ -50,7 +50,7 @@ use std::{
error::Error,
fs, io,
num::NonZeroU32,
path::{Path, PathBuf},
path::Path,
process,
sync::Arc,
time::{Duration, Instant},
@ -174,17 +174,12 @@ pub fn main() -> Result<(), Box<dyn Error>> {
}
let session_dirs = xdg::BaseDirectories::with_prefix("wayland-sessions")
.map_or(
vec![PathBuf::from("/usr/share/wayland-sessions")],
|xdg_dirs| xdg_dirs.get_data_dirs(),
)
.get_data_dirs()
.into_iter()
.map(|dir| (dir, SessionType::Wayland))
.chain(
xdg::BaseDirectories::with_prefix("xsessions")
.map_or(vec![PathBuf::from("/usr/share/xsessions")], |xdg_dirs| {
xdg_dirs.get_data_dirs()
})
.get_data_dirs()
.into_iter()
.map(|dir| (dir, SessionType::X11)),
);

View file

@ -1,12 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
use std::sync::OnceLock;
use i18n_embed::{
DefaultLocalizer, LanguageLoader, Localizer,
fluent::{FluentLanguageLoader, fluent_language_loader},
};
use rust_embed::RustEmbed;
use std::sync::OnceLock;
#[derive(RustEmbed)]
#[folder = "i18n/"]

View file

@ -1,5 +1,3 @@
use std::{str::FromStr, time::Duration};
use anyhow::bail;
use async_fn_stream::StreamEmitter;
use chrono::{Datelike, Timelike};
@ -7,20 +5,18 @@ use cosmic::{
Task,
iced_core::Element,
style,
widget::{self, column, text::title2},
widget::{column, text},
};
use futures_util::StreamExt;
use icu::{
calendar::DateTime,
datetime::{
DateTimeFormatter, DateTimeFormatterOptions,
options::{
components::{self, Bag},
preferences,
},
DateTimeFormatter, DateTimeFormatterPreferences, fieldsets,
input::{Date, DateTime, Time as IcuTime},
options::TimePrecision,
},
locid::Locale,
locale::{Locale, preferences::extensions::unicode::keywords::HourCycle},
};
use std::time::Duration;
use timedate_zbus::TimeDateProxy;
use tokio::time;
@ -33,24 +29,32 @@ pub struct Time {
impl Time {
pub fn new() -> Self {
fn get_local() -> Result<Locale, Box<dyn std::error::Error>> {
let locale = std::env::var("LC_TIME").or_else(|_| std::env::var("LANG"))?;
let locale = locale
.split('.')
.next()
.ok_or(format!("Can't split the locale {locale}"))?;
fn get_local() -> Locale {
for var in ["LC_TIME", "LC_ALL", "LANG"] {
if let Ok(locale_str) = std::env::var(var) {
let cleaned_locale = locale_str
.split('.')
.next()
.unwrap_or(&locale_str)
.replace('_', "-");
let locale = Locale::from_str(locale).map_err(|e| format!("{e:?}"))?;
Ok(locale)
if let Ok(locale) = Locale::try_from_str(&cleaned_locale) {
return locale;
}
// Try language-only fallback (e.g., "en" from "en-US")
if let Some(lang) = cleaned_locale.split('-').next() {
if let Ok(locale) = Locale::try_from_str(lang) {
return locale;
}
}
}
}
tracing::warn!("No valid locale found in environment, using fallback");
Locale::try_from_str("en-US").expect("Failed to parse fallback locale 'en-US'")
}
let locale = match get_local() {
Ok(locale) => locale,
Err(e) => {
tracing::error!("can't get locale {e}");
Locale::default()
}
};
let locale = get_local();
let now = chrono::Local::now().fixed_offset();
Self {
@ -72,59 +76,61 @@ impl Time {
.unwrap_or_else(|| chrono::Local::now().into());
}
pub fn format<D: Datelike>(&self, bag: Bag, date: &D) -> String {
let options = DateTimeFormatterOptions::Components(bag);
pub fn format_date<D: Datelike>(&self, date: &D) -> String {
let prefs = DateTimeFormatterPreferences::from(&self.locale);
let dtf = DateTimeFormatter::try_new(prefs, fieldsets::MDE::long()).unwrap();
let dtf =
DateTimeFormatter::try_new_experimental(&self.locale.clone().into(), options).unwrap();
let datetime = DateTime {
date: Date::try_new_gregorian(date.year(), date.month() as u8, date.day() as u8)
.unwrap(),
time: IcuTime::try_new(
self.now.hour() as u8,
self.now.minute() as u8,
self.now.second() as u8,
0,
)
.unwrap(),
};
let datetime = DateTime::try_new_gregorian_datetime(
date.year(),
date.month() as u8,
date.day() as u8,
// hack cause we know that we will only use "now"
// when we need hours (NaiveDate don't support this functions)
self.now.hour() as u8,
self.now.minute() as u8,
self.now.second() as u8,
dtf.format(&datetime).to_string()
}
pub fn format_time<D: Datelike>(&self, date: &D, military_time: bool) -> String {
let mut prefs = DateTimeFormatterPreferences::from(&self.locale);
prefs.hour_cycle = Some(if military_time {
HourCycle::H23
} else {
HourCycle::H12
});
let dtf = DateTimeFormatter::try_new(
prefs,
fieldsets::T::medium().with_time_precision(TimePrecision::Minute),
)
.unwrap()
.to_iso()
.to_any();
.unwrap();
dtf.format(&datetime)
.expect("can't format value")
.to_string()
let datetime = DateTime {
date: Date::try_new_gregorian(date.year(), date.month() as u8, date.day() as u8)
.unwrap(),
time: IcuTime::try_new(
self.now.hour() as u8,
self.now.minute() as u8,
self.now.second() as u8,
0,
)
.unwrap(),
};
dtf.format(&datetime).to_string()
}
pub fn date_time_widget<'a, M: 'a>(&self, military_time: bool) -> cosmic::Element<'a, M> {
let mut top_bag = Bag::empty();
top_bag.weekday = Some(components::Text::Long);
top_bag.day = Some(components::Day::NumericDayOfMonth);
top_bag.month = Some(components::Month::Long);
let mut bottom_bag = Bag::empty();
bottom_bag.hour = Some(components::Numeric::Numeric);
bottom_bag.minute = Some(components::Numeric::Numeric);
let hour_cycle = if military_time {
preferences::HourCycle::H23
} else {
preferences::HourCycle::H12
};
bottom_bag.preferences = Some(preferences::Bag::from_hour_cycle(hour_cycle));
Element::from(
column()
.padding(16.)
.spacing(12.0)
.push(title2(self.format(top_bag, &self.now)).class(style::Text::Accent))
.push(text::title2(self.format_date(&self.now)).class(style::Text::Accent))
.push(
widget::text(self.format(bottom_bag, &self.now))
text(self.format_time(&self.now, military_time))
.size(if military_time { 112. } else { 75. })
.class(style::Text::Accent),
),