File tree Expand file tree Collapse file tree 3 files changed +21
-27
lines changed
Expand file tree Collapse file tree 3 files changed +21
-27
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,17 @@ name = "cosmic-screenshot"
33version = " 0.1.0"
44edition = " 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
108chrono = " 0.4.24"
9+ clap = { version = " 4.4.16" , features = [" derive" ] }
1110dirs = " 5.0.1"
1211tokio = { 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
1514tracing = " 0.1"
1615tracing-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" ] }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1+ #![ allow( clippy:: too_many_arguments) ]
2+
13mod error;
24
3- use ashpd:: desktop:: screenshot:: { Screenshot , ScreenshotRequest } ;
5+ use ashpd:: desktop:: screenshot:: Screenshot ;
46use clap:: { command, ArgAction , Parser } ;
57use std:: { collections:: HashMap , fs, os:: unix:: fs:: MetadataExt , path:: PathBuf } ;
68use tracing:: { error, info} ;
79use 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
1512use 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 } ;
You can’t perform that action at this time.
0 commit comments