chore: add rustfmt config

This commit is contained in:
Vukašin Vojinović 2026-04-28 15:13:02 +02:00 committed by Michael Murphy
parent b021887c6c
commit 9895bd4b43
15 changed files with 136 additions and 144 deletions

15
.zed/settings.json Normal file
View file

@ -0,0 +1,15 @@
{
"format_on_save": "on",
"lsp": {
"rust-analyzer": {
"initialization_options": {
"check": {
"command": "clippy",
},
"rustfmt": {
"extraArgs": ["+nightly"],
},
},
},
},
}

View file

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

View file

@ -1,16 +1,15 @@
use cosmic_comp_config::output::randr; use cosmic_comp_config::output::randr;
use cosmic_config::CosmicConfigEntry; use cosmic_config::CosmicConfigEntry;
use kdl::KdlDocument; use kdl::KdlDocument;
use std::{ use std::collections::BTreeMap;
collections::BTreeMap, use std::fs;
fs, use std::io::Read;
io::Read, use std::os::unix::fs::OpenOptionsExt;
os::unix::fs::OpenOptionsExt, use std::path::{Path, PathBuf};
path::{Path, PathBuf},
};
pub use cosmic_applets_config::time::TimeAppletConfig; pub use cosmic_applets_config::time::TimeAppletConfig;
pub use cosmic_bg_config::{Color, Source as BgSource, state::State as BgState}; pub use cosmic_bg_config::state::State as BgState;
pub use cosmic_bg_config::{Color, Source as BgSource};
pub use cosmic_comp_config::{CosmicCompConfig, XkbConfig, ZoomConfig}; pub use cosmic_comp_config::{CosmicCompConfig, XkbConfig, ZoomConfig};
pub use cosmic_theme::{Theme, ThemeBuilder}; pub use cosmic_theme::{Theme, ThemeBuilder};

View file

@ -1,10 +1,15 @@
use color_eyre::eyre::Context; use color_eyre::eyre::Context;
use cosmic_greeter_daemon::{UserData, UserFilter}; use cosmic_greeter_daemon::{UserData, UserFilter};
use std::{env, error::Error, ffi::CString, future::pending, io}; use std::error::Error;
use std::ffi::CString;
use std::future::pending;
use std::{env, io};
use tracing::metadata::LevelFilter; use tracing::metadata::LevelFilter;
use tracing::warn; use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use tracing_subscriber::prelude::*;
use zbus::{DBusError, connection::Builder}; use tracing_subscriber::{EnvFilter, fmt};
use zbus::DBusError;
use zbus::connection::Builder;
//IMPORTANT: this function is critical to the security of this proxy. It must ensure that the //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 // callback is executed with the permissions of the specified user id. A good test is to see if

View file

@ -1,4 +1,5 @@
use greetd_ipc::{AuthMessageType, ErrorType, Request, Response, codec::TokioCodec}; use greetd_ipc::codec::TokioCodec;
use greetd_ipc::{AuthMessageType, ErrorType, Request, Response};
use std::{env, fs, io, thread}; use std::{env, fs, io, thread};
use tokio::net::UnixListener; use tokio::net::UnixListener;

1
rustfmt.toml Normal file
View file

@ -0,0 +1 @@
imports_granularity = "Module"

View file

@ -1,20 +1,15 @@
use cosmic::{ use cosmic::app::{Core, Task};
app::{Core, Task}, use cosmic::iced::core::SmolStr;
iced::runtime::core::window::Id as SurfaceId, use cosmic::iced::event::wayland::{Event as WaylandEvent, OutputEvent, SessionLockEvent};
iced::{ use cosmic::iced::event::{self};
self, Rectangle, Size, Subscription, use cosmic::iced::keyboard::{Event as KeyEvent, Key, Modifiers};
core::SmolStr, use cosmic::iced::runtime::core::window::Id as SurfaceId;
event::{ use cosmic::iced::{self, Rectangle, Size, Subscription};
self, use cosmic::widget;
wayland::{Event as WaylandEvent, OutputEvent, SessionLockEvent},
},
keyboard::{Event as KeyEvent, Key, Modifiers},
},
widget,
};
use cosmic_config::{ConfigSet, CosmicConfigEntry}; use cosmic_config::{ConfigSet, CosmicConfigEntry};
use cosmic_greeter_daemon::{BgSource, CosmicCompConfig, UserData}; use cosmic_greeter_daemon::{BgSource, CosmicCompConfig, UserData};
use std::{collections::HashMap, sync::Arc}; use std::collections::HashMap;
use std::sync::Arc;
use wayland_client::protocol::wl_output::WlOutput; use wayland_client::protocol::wl_output::WlOutput;
pub const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.; pub const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.;

View file

@ -8,63 +8,51 @@ use cctk::sctk::reexports::calloop;
use color_eyre::eyre::WrapErr; use color_eyre::eyre::WrapErr;
use cosmic::app::{Core, Settings, Task}; use cosmic::app::{Core, Settings, Task};
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity; use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
use cosmic::cosmic_config::{self, ConfigSet};
use cosmic::cosmic_theme::{self, CosmicPalette};
use cosmic::desktop::fde::{DesktopEntry, get_languages_from_env};
use cosmic::iced::event::listen_with; use cosmic::iced::event::listen_with;
use cosmic::iced::runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings; use cosmic::iced::event::wayland::OutputEvent;
use cosmic::iced::{Point, Size, window}; use cosmic::iced::futures::SinkExt;
use cosmic::widget::{id_container, text}; use cosmic::iced::platform_specific::runtime::wayland::layer_surface::{
use cosmic::{ IcedMargin, IcedOutput, SctkLayerSurfaceSettings,
Element, };
cosmic_config::{self, ConfigSet}, use cosmic::iced::platform_specific::shell::wayland::commands::layer_surface::{
executor,
iced::runtime::core::window::Id as SurfaceId,
iced::{
self, Alignment, Background, Border, Length, Subscription,
event::wayland::OutputEvent,
futures::SinkExt,
platform_specific::{
runtime::wayland::layer_surface::{IcedMargin, IcedOutput, SctkLayerSurfaceSettings},
shell::wayland::commands::layer_surface::{
Anchor, KeyboardInteractivity, Layer, destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity, Layer, destroy_layer_surface, get_layer_surface,
},
shell::wayland::commands::subsurface::reposition_subsurface,
},
},
theme, widget,
}; };
use cosmic::{ use cosmic::iced::platform_specific::shell::wayland::commands::subsurface::reposition_subsurface;
cosmic_theme::{self, CosmicPalette}, use cosmic::iced::runtime::core::window::Id as SurfaceId;
desktop::fde::{DesktopEntry, get_languages_from_env}, use cosmic::iced::runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings;
surface, use cosmic::iced::{
self, Alignment, Background, Border, Length, Point, Size, Subscription, window,
}; };
use cosmic::widget::{id_container, text};
use cosmic::{Element, executor, surface, theme, widget};
use cosmic_greeter_config::Config as CosmicGreeterConfig; use cosmic_greeter_config::Config as CosmicGreeterConfig;
use cosmic_greeter_daemon::{UserData, UserFilter}; use cosmic_greeter_daemon::{UserData, UserFilter};
use cosmic_randr_shell::{KdlParseWithError, List}; use cosmic_randr_shell::{KdlParseWithError, List};
use cosmic_settings_a11y_manager_subscription::{AccessibilityEvent, AccessibilityRequest}; use cosmic_settings_a11y_manager_subscription::{AccessibilityEvent, AccessibilityRequest};
use greetd_ipc::Request; use greetd_ipc::Request;
use kdl::KdlDocument; use kdl::KdlDocument;
use std::collections::{HashMap, hash_map};
use std::error::Error;
use std::num::NonZeroU32;
use std::process::Stdio; use std::process::Stdio;
use std::sync::LazyLock; use std::sync::{Arc, LazyLock};
use std::{ use std::time::{Duration, Instant};
collections::{HashMap, hash_map}, use std::{fs, io, process};
error::Error,
fs, io,
num::NonZeroU32,
process,
sync::Arc,
time::{Duration, Instant},
};
use tokio::process::Child; use tokio::process::Child;
use tokio::time; use tokio::time;
use tracing::metadata::LevelFilter; use tracing::metadata::LevelFilter;
use tracing::warn; use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use tracing_subscriber::prelude::*;
use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use tracing_subscriber::{EnvFilter, fmt};
use wayland_client::Proxy;
use wayland_client::protocol::wl_output::WlOutput;
use zbus::{Connection, proxy}; use zbus::{Connection, proxy};
use crate::{ use crate::common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT};
common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT}, use crate::fl;
fl,
};
static USERNAME_ID: LazyLock<iced::id::Id> = LazyLock::new(|| iced::id::Id::new("username-id")); static USERNAME_ID: LazyLock<iced::id::Id> = LazyLock::new(|| iced::id::Id::new("username-id"));

View file

@ -1,9 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use i18n_embed::{ use i18n_embed::fluent::{FluentLanguageLoader, fluent_language_loader};
DefaultLocalizer, LanguageLoader, Localizer, use i18n_embed::{DefaultLocalizer, LanguageLoader, Localizer};
fluent::{FluentLanguageLoader, fluent_language_loader},
};
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
use std::sync::OnceLock; use std::sync::OnceLock;

View file

@ -4,45 +4,37 @@
use color_eyre::eyre::WrapErr; use color_eyre::eyre::WrapErr;
use cosmic::app::{Core, Settings, Task}; use cosmic::app::{Core, Settings, Task};
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity; use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
use cosmic::iced::runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings; use cosmic::iced::event::wayland::{OutputEvent, SessionLockEvent};
use cosmic::iced::{Point, Rectangle, Size}; use cosmic::iced::futures::{self, SinkExt};
use cosmic::surface; use cosmic::iced::platform_specific::shell::wayland::commands::session_lock::{
use cosmic::{
Element, executor,
iced::runtime::core::window::Id as SurfaceId,
iced::{
self, Alignment, Background, Border, Length, Subscription,
event::wayland::{OutputEvent, SessionLockEvent},
futures::{self, SinkExt},
platform_specific::shell::wayland::commands::session_lock::{
destroy_lock_surface, get_lock_surface, lock, unlock, destroy_lock_surface, get_lock_surface, lock, unlock,
},
},
theme, widget,
}; };
use cosmic::iced::runtime::core::window::Id as SurfaceId;
use cosmic::iced::runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings;
use cosmic::iced::{
self, Alignment, Background, Border, Length, Point, Rectangle, Size, Subscription,
};
use cosmic::{Element, executor, surface, theme, widget};
use cosmic_config::CosmicConfigEntry; use cosmic_config::CosmicConfigEntry;
use cosmic_greeter_daemon::{TimeAppletConfig, UserData}; use cosmic_greeter_daemon::{TimeAppletConfig, UserData};
use std::any::TypeId;
use std::ffi::{CStr, CString};
use std::os::fd::OwnedFd;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use std::{ use std::{env, fs, process};
any::TypeId, use tokio::sync::mpsc;
env, use tokio::task;
ffi::{CStr, CString},
fs,
os::fd::OwnedFd,
path::PathBuf,
process,
sync::Arc,
};
use tokio::{sync::mpsc, task};
use tracing::level_filters::LevelFilter; use tracing::level_filters::LevelFilter;
use tracing::warn; use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use tracing_subscriber::prelude::*;
use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use tracing_subscriber::{EnvFilter, fmt};
use wayland_client::Proxy;
use wayland_client::protocol::wl_output::WlOutput;
use crate::{ use crate::common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT};
common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT}, use crate::fl;
fl,
};
fn lockfile_opt() -> Option<PathBuf> { fn lockfile_opt() -> Option<PathBuf> {
let runtime_dir = dirs::runtime_dir()?; let runtime_dir = dirs::runtime_dir()?;

View file

@ -1,15 +1,17 @@
use cosmic::iced::{ use cosmic::iced::Subscription;
Subscription, use cosmic::iced::futures::channel::mpsc;
futures::{SinkExt, StreamExt, channel::mpsc}, use cosmic::iced::futures::{SinkExt, StreamExt};
}; use logind_zbus::manager::{InhibitType, ManagerProxy};
use logind_zbus::{ use logind_zbus::session::SessionProxy;
manager::{InhibitType, ManagerProxy}, use std::any::TypeId;
session::SessionProxy, use std::error::Error;
}; use std::os::fd::OwnedFd;
use std::{any::TypeId, error::Error, os::fd::OwnedFd, sync::Arc, time::Duration}; use std::sync::Arc;
use std::time::Duration;
use zbus::Connection; use zbus::Connection;
use crate::{common, locker::Message}; use crate::common;
use crate::locker::Message;
pub async fn power_off() -> zbus::Result<()> { pub async fn power_off() -> zbus::Result<()> {
let connection = Connection::system().await?; let connection = Connection::system().await?;

View file

@ -1,9 +1,11 @@
use cosmic::iced::{ use cosmic::iced::Subscription;
Subscription, use cosmic::iced::futures::channel::mpsc;
futures::{SinkExt, StreamExt, channel::mpsc}, use cosmic::iced::futures::{SinkExt, StreamExt};
}; use cosmic_dbus_networkmanager::device::SpecificDevice;
use cosmic_dbus_networkmanager::{device::SpecificDevice, nm::NetworkManager}; use cosmic_dbus_networkmanager::nm::NetworkManager;
use std::{any::TypeId, cmp, time::Duration}; use std::any::TypeId;
use std::cmp;
use std::time::Duration;
use zbus::{Connection, Result}; use zbus::{Connection, Result};
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View file

@ -1,17 +1,13 @@
use anyhow::bail; use anyhow::bail;
use async_fn_stream::StreamEmitter; use async_fn_stream::StreamEmitter;
use cosmic::{ use cosmic::widget::{column, text};
Element, Task, style, use cosmic::{Element, Task, style};
widget::{column, text},
};
use futures_util::StreamExt; use futures_util::StreamExt;
use icu::{ use icu::datetime::input::DateTime;
datetime::{ use icu::datetime::options::TimePrecision;
DateTimeFormatter, DateTimeFormatterPreferences, fieldsets, input::DateTime, use icu::datetime::{DateTimeFormatter, DateTimeFormatterPreferences, fieldsets};
options::TimePrecision, use icu::locale::Locale;
}, use icu::locale::preferences::extensions::unicode::keywords::HourCycle;
locale::{Locale, preferences::extensions::unicode::keywords::HourCycle},
};
use jiff::tz::TimeZone; use jiff::tz::TimeZone;
use jiff_icu::ConvertFrom; use jiff_icu::ConvertFrom;
use std::time::Duration; use std::time::Duration;

View file

@ -1,10 +1,9 @@
use cosmic::iced::{ use cosmic::iced::futures::channel::mpsc;
Subscription, use cosmic::iced::futures::{SinkExt, StreamExt};
futures::{SinkExt, StreamExt, channel::mpsc}, use cosmic::iced::{Subscription, stream};
stream,
};
use futures_util::select; use futures_util::select;
use std::{any::TypeId, time::Duration}; use std::any::TypeId;
use std::time::Duration;
use upower_dbus::{BatteryState, BatteryType, UPowerProxy}; use upower_dbus::{BatteryState, BatteryType, UPowerProxy};
use zbus::{Connection, Result}; use zbus::{Connection, Result};

View file

@ -2,11 +2,8 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use cctk::sctk::reexports::calloop; use cctk::sctk::reexports::calloop;
use cosmic::iced::{ use cosmic::iced::futures::{self, SinkExt};
self, Subscription, use cosmic::iced::{self, Subscription, stream};
futures::{self, SinkExt},
stream,
};
use cosmic_settings_a11y_manager_subscription::{ use cosmic_settings_a11y_manager_subscription::{
self as thread, AccessibilityEvent, AccessibilityRequest, self as thread, AccessibilityEvent, AccessibilityRequest,
}; };