chore: clippy
This commit is contained in:
parent
a7f8a62807
commit
7bab53c5b4
5 changed files with 79 additions and 101 deletions
|
|
@ -45,7 +45,7 @@ impl UserData {
|
||||||
//TODO: do not reread duplicate paths, cache data by path?
|
//TODO: do not reread duplicate paths, cache data by path?
|
||||||
BgSource::Path(path) => {
|
BgSource::Path(path) => {
|
||||||
if !self.bg_path_data.contains_key(path) {
|
if !self.bg_path_data.contains_key(path) {
|
||||||
match fs::read(&path) {
|
match fs::read(path) {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
self.bg_path_data.insert(path.clone(), bytes);
|
self.bg_path_data.insert(path.clone(), bytes);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,15 +49,13 @@ async fn main() {
|
||||||
auth_message_type: AuthMessageType::Secret,
|
auth_message_type: AuthMessageType::Secret,
|
||||||
auth_message: "MOCKING:".to_string(),
|
auth_message: "MOCKING:".to_string(),
|
||||||
},
|
},
|
||||||
Request::PostAuthMessageResponse { response } => {
|
Request::PostAuthMessageResponse { response } => match response.as_deref() {
|
||||||
match response.as_ref().map(|x| x.as_str()) {
|
Some("password") => Response::Success,
|
||||||
Some("password") => Response::Success,
|
_ => Response::Error {
|
||||||
_ => Response::Error {
|
error_type: ErrorType::AuthError,
|
||||||
error_type: ErrorType::AuthError,
|
description: "pam_authenticate: AUTH_ERR".to_string(),
|
||||||
description: "pam_authenticate: AUTH_ERR".to_string(),
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
Request::StartSession { .. } => Response::Success,
|
Request::StartSession { .. } => Response::Success,
|
||||||
Request::CancelSession => Response::Success,
|
Request::CancelSession => Response::Success,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
125
src/greeter.rs
125
src/greeter.rs
|
|
@ -37,7 +37,7 @@ use cosmic::{
|
||||||
};
|
};
|
||||||
use cosmic_greeter_config::Config as CosmicGreeterConfig;
|
use cosmic_greeter_config::Config as CosmicGreeterConfig;
|
||||||
use cosmic_greeter_daemon::UserData;
|
use cosmic_greeter_daemon::UserData;
|
||||||
use cosmic_randr_shell::{AdaptiveSyncState, KdlParseWithError, List, OutputKey, Transform};
|
use cosmic_randr_shell::{KdlParseWithError, List};
|
||||||
use cosmic_settings_subscriptions::cosmic_a11y_manager::{
|
use cosmic_settings_subscriptions::cosmic_a11y_manager::{
|
||||||
AccessibilityEvent, AccessibilityRequest,
|
AccessibilityEvent, AccessibilityRequest,
|
||||||
};
|
};
|
||||||
|
|
@ -291,11 +291,8 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::info!("session {} using command {:?} env {:?}", name, command, env);
|
tracing::info!("session {} using command {:?} env {:?}", name, command, env);
|
||||||
match sessions.insert(name.to_string(), (command, env)) {
|
if let Some(some) = sessions.insert(name.to_string(), (command, env)) {
|
||||||
Some(some) => {
|
tracing::warn!("session {} overwrote old command {:?}", name, some);
|
||||||
tracing::warn!("session {} overwrote old command {:?}", name, some);
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +673,7 @@ impl App {
|
||||||
items.push(menu_checklist(
|
items.push(menu_checklist(
|
||||||
fl!("accessibility", "screen-reader"),
|
fl!("accessibility", "screen-reader"),
|
||||||
self.accessibility.screen_reader.is_some(),
|
self.accessibility.screen_reader.is_some(),
|
||||||
Message::ScreenReader(!self.accessibility.screen_reader.is_some()),
|
Message::ScreenReader(self.accessibility.screen_reader.is_none()),
|
||||||
));
|
));
|
||||||
items.push(menu_checklist(
|
items.push(menu_checklist(
|
||||||
fl!("accessibility", "magnifier"),
|
fl!("accessibility", "magnifier"),
|
||||||
|
|
@ -772,19 +769,16 @@ impl App {
|
||||||
{
|
{
|
||||||
if !self.entering_name && user_data.name == self.selected_username.username
|
if !self.entering_name && user_data.name == self.selected_username.username
|
||||||
{
|
{
|
||||||
match user_icon {
|
if let Some(icon) = user_icon {
|
||||||
Some(icon) => {
|
column = column.push(
|
||||||
column = column.push(
|
widget::container(
|
||||||
widget::container(
|
widget::image(icon)
|
||||||
widget::image(icon)
|
.width(Length::Fixed(78.0))
|
||||||
.width(Length::Fixed(78.0))
|
.height(Length::Fixed(78.0)),
|
||||||
.height(Length::Fixed(78.0)),
|
|
||||||
)
|
|
||||||
.width(Length::Fill)
|
|
||||||
.align_x(Alignment::Center),
|
|
||||||
)
|
)
|
||||||
}
|
.width(Length::Fill)
|
||||||
None => {}
|
.align_x(Alignment::Center),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
column = column.push(
|
column = column.push(
|
||||||
widget::container(widget::text::title4(&user_data.full_name))
|
widget::container(widget::text::title4(&user_data.full_name))
|
||||||
|
|
@ -801,11 +795,11 @@ impl App {
|
||||||
)
|
)
|
||||||
.id(USERNAME_ID.clone())
|
.id(USERNAME_ID.clone())
|
||||||
.on_input(|input| Message::EnterUser(false, input))
|
.on_input(|input| Message::EnterUser(false, input))
|
||||||
.on_submit(|v| Message::Username(v)),
|
.on_submit(Message::Username),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
match &self.common.prompt_opt {
|
if let Some((prompt, secret, value_opt)) = &self.common.prompt_opt {
|
||||||
Some((prompt, secret, value_opt)) => match value_opt {
|
match value_opt {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let text_input_id = self
|
let text_input_id = self
|
||||||
.common
|
.common
|
||||||
|
|
@ -860,8 +854,7 @@ impl App {
|
||||||
widget::button::custom("Confirm").on_press(Message::Auth(None)),
|
widget::button::custom("Confirm").on_press(Message::Auth(None)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketState::NotSet => {
|
SocketState::NotSet => {
|
||||||
|
|
@ -981,7 +974,7 @@ impl App {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.common.set_xkb_config(&user_data);
|
self.common.set_xkb_config(user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_user_data(&mut self) -> Task<Message> {
|
fn update_user_data(&mut self) -> Task<Message> {
|
||||||
|
|
@ -996,10 +989,10 @@ impl App {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.common.update_user_data(&user_data);
|
self.common.update_user_data(user_data);
|
||||||
|
|
||||||
// Ensure that user's xkb config is used
|
// Ensure that user's xkb config is used
|
||||||
self.common.set_xkb_config(&user_data);
|
self.common.set_xkb_config(user_data);
|
||||||
|
|
||||||
if let Some(builder) = &user_data.theme_builder_opt {
|
if let Some(builder) = &user_data.theme_builder_opt {
|
||||||
self.theme_builder = builder.clone();
|
self.theme_builder = builder.clone();
|
||||||
|
|
@ -1097,9 +1090,11 @@ impl cosmic::Application for App {
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let data_idx = Some(0);
|
let data_idx = Some(0);
|
||||||
let selected_username = NameIndexPair { username, data_idx };
|
let selected_username = NameIndexPair { username, data_idx };
|
||||||
let mut accessibility = Accessibility::default();
|
let accessibility = Accessibility {
|
||||||
accessibility.helper =
|
helper: cosmic_settings_daemon_config::greeter::GreeterAccessibilityState::config()
|
||||||
cosmic_settings_daemon_config::greeter::GreeterAccessibilityState::config().ok();
|
.ok(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
let app = App {
|
let app = App {
|
||||||
common,
|
common,
|
||||||
|
|
@ -1135,19 +1130,17 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
let surface_id = SurfaceId::unique();
|
let surface_id = SurfaceId::unique();
|
||||||
let subsurface_id = SurfaceId::unique();
|
let subsurface_id = SurfaceId::unique();
|
||||||
self.surface_id_pairs
|
self.surface_id_pairs.push((surface_id, subsurface_id));
|
||||||
.push((surface_id.clone(), subsurface_id.clone()));
|
|
||||||
|
|
||||||
match self.common.surface_ids.insert(output.clone(), surface_id) {
|
if let Some(old_surface_id) =
|
||||||
Some(old_surface_id) => {
|
self.common.surface_ids.insert(output.clone(), surface_id)
|
||||||
//TODO: remove old surface?
|
{
|
||||||
tracing::warn!(
|
//TODO: remove old surface?
|
||||||
"output {}: already had surface ID {:?}",
|
tracing::warn!(
|
||||||
output.id(),
|
"output {}: already had surface ID {:?}",
|
||||||
old_surface_id
|
output.id(),
|
||||||
);
|
old_surface_id
|
||||||
}
|
);
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
let size = if let Some((w, h)) =
|
let size = if let Some((w, h)) =
|
||||||
output_info_opt.as_ref().and_then(|info| info.logical_size)
|
output_info_opt.as_ref().and_then(|info| info.logical_size)
|
||||||
|
|
@ -1264,14 +1257,11 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::Socket(socket_state) => {
|
Message::Socket(socket_state) => {
|
||||||
self.socket_state = socket_state;
|
self.socket_state = socket_state;
|
||||||
match &self.socket_state {
|
if let SocketState::Open = &self.socket_state {
|
||||||
SocketState::Open => {
|
// When socket is opened, send create session
|
||||||
// When socket is opened, send create session
|
self.send_request(Request::CreateSession {
|
||||||
self.send_request(Request::CreateSession {
|
username: self.selected_username.username.clone(),
|
||||||
username: self.selected_username.username.clone(),
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Reload(new) => {
|
Message::Reload(new) => {
|
||||||
|
|
@ -1329,12 +1319,9 @@ impl cosmic::Application for App {
|
||||||
}) {
|
}) {
|
||||||
session.clone_into(&mut self.selected_session);
|
session.clone_into(&mut self.selected_session);
|
||||||
};
|
};
|
||||||
match &self.socket_state {
|
if let SocketState::Open = &self.socket_state {
|
||||||
SocketState::Open => {
|
self.common.prompt_opt = None;
|
||||||
self.common.prompt_opt = None;
|
self.send_request(Request::CancelSession);
|
||||||
self.send_request(Request::CancelSession);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
if let Some(randr_list) = self.randr_list.as_ref() {
|
if let Some(randr_list) = self.randr_list.as_ref() {
|
||||||
return self.update(Message::RandrUpdate {
|
return self.update(Message::RandrUpdate {
|
||||||
|
|
@ -1372,7 +1359,7 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
let uid = *user_entry.key();
|
let uid = *user_entry.key();
|
||||||
self.flags.greeter_config.last_user = Some(uid);
|
self.flags.greeter_config.last_user = Some(uid);
|
||||||
if let Err(err) = handler.set("last_user", &self.flags.greeter_config.last_user) {
|
if let Err(err) = handler.set("last_user", self.flags.greeter_config.last_user) {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"Failed to set {:?} as last user: {:?}",
|
"Failed to set {:?} as last user: {:?}",
|
||||||
self.flags.greeter_config.last_user,
|
self.flags.greeter_config.last_user,
|
||||||
|
|
@ -1573,22 +1560,20 @@ impl cosmic::Application for App {
|
||||||
{
|
{
|
||||||
self.accessibility.screen_reader =
|
self.accessibility.screen_reader =
|
||||||
tokio::process::Command::new("/usr/bin/orca").spawn().ok();
|
tokio::process::Command::new("/usr/bin/orca").spawn().ok();
|
||||||
} else {
|
} else if let Some(mut c) = self.accessibility.screen_reader.take() {
|
||||||
if let Some(mut c) = self.accessibility.screen_reader.take() {
|
return cosmic::task::future::<(), ()>(async move {
|
||||||
return cosmic::task::future::<(), ()>(async move {
|
if let Err(err) = c.kill().await {
|
||||||
if let Err(err) = c.kill().await {
|
tracing::error!("Failed to stop screen reader: {err:?}");
|
||||||
tracing::error!("Failed to stop screen reader: {err:?}");
|
}
|
||||||
}
|
})
|
||||||
})
|
.discard();
|
||||||
.discard();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(helper) = self.accessibility.helper.as_ref() {
|
if let Some(helper) = self.accessibility.helper.as_ref() {
|
||||||
_ = self
|
_ = self
|
||||||
.accessibility
|
.accessibility
|
||||||
.state
|
.state
|
||||||
.set_screen_reader(&helper, Some(enabled));
|
.set_screen_reader(helper, Some(enabled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Magnifier(enabled) => {
|
Message::Magnifier(enabled) => {
|
||||||
|
|
@ -1599,7 +1584,7 @@ impl cosmic::Application for App {
|
||||||
_ = self
|
_ = self
|
||||||
.accessibility
|
.accessibility
|
||||||
.state
|
.state
|
||||||
.set_magnifier(&helper, Some(enabled));
|
.set_magnifier(helper, Some(enabled));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.accessibility.magnifier = false;
|
self.accessibility.magnifier = false;
|
||||||
|
|
@ -1612,7 +1597,7 @@ impl cosmic::Application for App {
|
||||||
_ = self
|
_ = self
|
||||||
.accessibility
|
.accessibility
|
||||||
.state
|
.state
|
||||||
.set_high_contrast(&helper, Some(enabled));
|
.set_high_contrast(helper, Some(enabled));
|
||||||
}
|
}
|
||||||
let builder = self.theme_builder.clone();
|
let builder = self.theme_builder.clone();
|
||||||
|
|
||||||
|
|
@ -1648,7 +1633,7 @@ impl cosmic::Application for App {
|
||||||
_ = self
|
_ = self
|
||||||
.accessibility
|
.accessibility
|
||||||
.state
|
.state
|
||||||
.set_invert_colors(&helper, Some(enabled));
|
.set_invert_colors(helper, Some(enabled));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.accessibility.invert_colors = false;
|
self.accessibility.invert_colors = false;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ pub fn main(user: pwd::Passwd) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
user_icon: user_data
|
user_icon: user_data
|
||||||
.icon_opt
|
.icon_opt
|
||||||
.take()
|
.take()
|
||||||
.map(|icon| widget::image::Handle::from_bytes(icon)),
|
.map(widget::image::Handle::from_bytes),
|
||||||
user_data,
|
user_data,
|
||||||
lockfile_opt: lockfile_opt(),
|
lockfile_opt: lockfile_opt(),
|
||||||
};
|
};
|
||||||
|
|
@ -418,23 +418,20 @@ impl App {
|
||||||
};
|
};
|
||||||
|
|
||||||
let right_element = {
|
let right_element = {
|
||||||
let mut column = widget::column::with_capacity(2)
|
let mut column = widget::column::with_capacity(5)
|
||||||
.spacing(12.0)
|
.spacing(12.0)
|
||||||
.max_width(280.0);
|
.max_width(280.0);
|
||||||
|
|
||||||
match &self.flags.user_icon {
|
if let Some(icon) = &self.flags.user_icon {
|
||||||
Some(icon) => {
|
column = column.push(
|
||||||
column = column.push(
|
widget::container(
|
||||||
widget::container(
|
widget::image(icon)
|
||||||
widget::image(icon)
|
.width(Length::Fixed(78.0))
|
||||||
.width(Length::Fixed(78.0))
|
.height(Length::Fixed(78.0)),
|
||||||
.height(Length::Fixed(78.0)),
|
|
||||||
)
|
|
||||||
.width(Length::Fill)
|
|
||||||
.align_x(Alignment::Center),
|
|
||||||
)
|
)
|
||||||
}
|
.width(Length::Fill)
|
||||||
None => {}
|
.align_x(Alignment::Center),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
column = column.push(
|
column = column.push(
|
||||||
|
|
@ -443,8 +440,8 @@ impl App {
|
||||||
.align_x(Alignment::Center),
|
.align_x(Alignment::Center),
|
||||||
);
|
);
|
||||||
|
|
||||||
match &self.common.prompt_opt {
|
if let Some((prompt, secret, value_opt)) = &self.common.prompt_opt {
|
||||||
Some((prompt, secret, value_opt)) => match value_opt {
|
match value_opt {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let text_input_id = self
|
let text_input_id = self
|
||||||
.common
|
.common
|
||||||
|
|
@ -488,8 +485,7 @@ impl App {
|
||||||
None => {
|
None => {
|
||||||
column = column.push(widget::text(prompt));
|
column = column.push(widget::text(prompt));
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(error) = &self.common.error_opt {
|
if let Some(error) = &self.common.error_opt {
|
||||||
|
|
@ -567,7 +563,7 @@ impl cosmic::Application for App {
|
||||||
common.on_output_event = Some(Box::new(|output_event, output| {
|
common.on_output_event = Some(Box::new(|output_event, output| {
|
||||||
Message::OutputEvent(output_event, output)
|
Message::OutputEvent(output_event, output)
|
||||||
}));
|
}));
|
||||||
common.on_session_lock_event = Some(Box::new(|evt| Message::SessionLockEvent(evt)));
|
common.on_session_lock_event = Some(Box::new(Message::SessionLockEvent));
|
||||||
common.update_user_data(&flags.user_data);
|
common.update_user_data(&flags.user_data);
|
||||||
|
|
||||||
let already_locked = match flags.lockfile_opt {
|
let already_locked = match flags.lockfile_opt {
|
||||||
|
|
@ -1017,7 +1013,7 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
for (_output, surface_id) in self.common.surface_ids.iter() {
|
for (_output, surface_id) in self.common.surface_ids.iter() {
|
||||||
self.common.surface_names.remove(surface_id);
|
self.common.surface_names.remove(surface_id);
|
||||||
self.common.window_size.remove(&surface_id);
|
self.common.window_size.remove(surface_id);
|
||||||
commands.push(destroy_lock_surface(*surface_id));
|
commands.push(destroy_lock_surface(*surface_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use anyhow;
|
|
||||||
use cctk::sctk::reexports::calloop;
|
use cctk::sctk::reexports::calloop;
|
||||||
use cosmic::iced::{
|
use cosmic::iced::{
|
||||||
self, Subscription,
|
self, Subscription,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue