Skip to content

Commit 63bb42f

Browse files
Placate Clippy, organize Cargo.toml
1 parent ec7d80d commit 63bb42f

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ name = "cosmic-screenshot"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
9-
ashpd = { version = "0.6.8", features = ["tracing"] }
7+
# App
108
chrono = "0.4.24"
9+
clap = { version = "4.4.16", features = ["derive"] }
1110
dirs = "5.0.1"
1211
tokio = { version = "1.28.1", features = ["full"] }
13-
clap = { version = "4.4.16", features = ["derive"] }
14-
zbus = { version = "3", default-features = false, features = ["tokio"] }
12+
13+
# Logging
1514
tracing = "0.1"
1615
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
16+
17+
# Screenshots/D-Bus comm
18+
ashpd = { version = "0.6.8", features = ["tracing"] }
19+
zbus = { version = "3", default-features = false, features = ["tokio"] }

src/error.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ impl Error {
6666
)
6767
})
6868
.unwrap_or_else(|| "Unable to save screenshot to the Pictures directory".into()),
69-
Self::Ashpd(e) => match e {
70-
AshpdError::Portal(e) => match e {
71-
PortalError::NotAllowed(msg) => format!("Screenshot not allowed: {msg}"),
72-
_ => "Failed to take screenshot".into(),
73-
},
74-
_ => "Failed to take screenshot".into(),
75-
},
69+
Self::Ashpd(AshpdError::Portal(PortalError::NotAllowed(msg))) => {
70+
format!("Screenshot not allowed: {msg}")
71+
}
7672
Self::SaveScreenshot { .. } => "Screenshot succeeded but couldn't be saved".into(),
7773
_ => "Failed to take screenshot".into(),
7874
}
@@ -86,13 +82,7 @@ impl Error {
8682

8783
match e {
8884
AshpdError::Response(e) => *e == ResponseError::Cancelled,
89-
AshpdError::Portal(e) => {
90-
if let PortalError::Cancelled(_) = e {
91-
true
92-
} else {
93-
false
94-
}
95-
}
85+
AshpdError::Portal(PortalError::Cancelled(_)) => true,
9686
_ => false,
9787
}
9888
}

src/main.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1+
#![allow(clippy::too_many_arguments)]
2+
13
mod error;
24

3-
use ashpd::desktop::screenshot::{Screenshot, ScreenshotRequest};
5+
use ashpd::desktop::screenshot::Screenshot;
46
use clap::{command, ArgAction, Parser};
57
use std::{collections::HashMap, fs, os::unix::fs::MetadataExt, path::PathBuf};
68
use tracing::{error, info};
79
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
8-
use zbus::{
9-
dbus_proxy,
10-
export::futures_util::{future::FutureExt, TryFutureExt},
11-
zvariant::Value,
12-
Connection,
13-
};
10+
use zbus::{dbus_proxy, zvariant::Value, Connection};
1411

1512
use error::Error;
1613

@@ -169,7 +166,11 @@ async fn main() -> Result<(), Error> {
169166
path
170167
}
171168
Err(e) => {
172-
error!("Screenshot failed with {e}");
169+
if !e.cancelled() {
170+
error!("Screenshot failed with {e}");
171+
} else {
172+
info!("Screenshot cancelled");
173+
}
173174
e.to_user_facing()
174175
}
175176
};

0 commit comments

Comments
 (0)