diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b3e620a..679293f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -11,8 +11,8 @@ //"/home/gabm/Pictures/Wallpaper/torres_1.jpg", "/home/gabm/Pictures/Screenshots/satty-20231116-10:35:51.png", //"--fullscreen", - "--output-filename", - "/tmp/out.png", + //"--output-filename", + //"/tmp/out.png", "--copy-command", "wl-copy", ], diff --git a/Cargo.lock b/Cargo.lock index 67a1d77..3b2b8c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,21 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.5" @@ -183,6 +198,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.48.5", +] + [[package]] name = "clap" version = "4.4.11" @@ -258,6 +287,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "crc32fast" version = "1.3.2" @@ -730,6 +765,29 @@ dependencies = [ "serde", ] +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "indexmap" version = "2.1.0" @@ -869,6 +927,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -1195,6 +1262,7 @@ name = "satty" version = "0.8.3" dependencies = [ "anyhow", + "chrono", "clap", "clap_complete", "clap_complete_fig", @@ -1611,6 +1679,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index ee0d456..4fa7c1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,8 @@ toml = "0.8.8" serde = "1.0" serde_derive = "1.0" hex_color = {version = "3", features = ["serde"]} +chrono = "0.4.31" + [dependencies.relm4-icons] version = "0.6.0" diff --git a/src/configuration.rs b/src/configuration.rs index deacc82..16df058 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -131,7 +131,9 @@ impl Configuration { if let Some(v) = general.copy_command { self.copy_command = Some(v); } - // output_filename is not yet supported + if let Some(v) = general.output_filename { + self.output_filename = Some(v); + } if let Some(v) = general.annotation_size_factor { self.annotation_size_factor = v; } @@ -247,6 +249,7 @@ struct ConfiguationFileGeneral { initial_tool: Option, copy_command: Option, annotation_size_factor: Option, + output_filename: Option, } #[derive(Deserialize)] diff --git a/src/sketch_board.rs b/src/sketch_board.rs index c13dcb4..6f4edc1 100644 --- a/src/sketch_board.rs +++ b/src/sketch_board.rs @@ -1,4 +1,5 @@ use anyhow::anyhow; +use chrono::format::strftime; use gdk_pixbuf::Pixbuf; use std::cell::RefCell; use std::fs; @@ -151,6 +152,9 @@ impl SketchBoard { Some(o) => o.clone(), }; + // run the output filename by "chrono date format" + let output_filename = format!("{}", chrono::Local::now().format(&output_filename)); + if !output_filename.ends_with(".png") { let msg = "The only supported format is png, but the filename does not end in png"; println!("{msg}");